Jump to content


how to set default value to hidden field


  • Please log in to reply
1 reply to this topic

#1 irshadjan

irshadjan

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 04 August 2019 - 03:07 PM

May i know how can i set default value for hidden fields since i am using fieldType('fieldname','hidden','my default value') but its not working value is not update which i pass as third parameter to this function. I am using the latest version of Grocery Crud enterprise Grocery CRUD Enterprise v2.7.9

 

 



#2 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,101 posts
  • LocationLondon

Posted 13 August 2019 - 03:50 PM

May i know how can i set default value for hidden fields since i am using fieldType('fieldname','hidden','my default value') but its not working value is not update which i pass as third parameter to this function. I am using the latest version of Grocery Crud enterprise Grocery CRUD Enterprise v2.7.9

 

Hello @

 

You should use the function: callbackEditForm (https://www.groceryc...llbackEditForm/) in order to achieve that. More specifically in your case you will do something like this:

$defaultValues = function ($data) {
    $data['fieldname'] = 'my default value';

    return $data;
};
$crud->fieldType('fieldname','hidden','my default value');
$crud->callbackAddForm($defaultValues);
$crud->callbackEditForm($defaultValues);


Let me know if that worked for you

 

Regards

Johnny


Posted Image




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users