Hi, I want to know if is there a way to add some aclarations or anotations for fields into a groceryCrud form, in order to clarify what information should the user enter in some tricky fields.
Thanks.
⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠
Posted 10 February 2015 - 06:29 AM
Hi, I want to know if is there a way to add some aclarations or anotations for fields into a groceryCrud form, in order to clarify what information should the user enter in some tricky fields.
Thanks.
Posted 11 February 2015 - 16:18 PM
Hi there
even i wanted the same solution so had buit 1 for myself.. you surely can change it according to things that suite u
class Grocery_CRUD extends grocery_CRUD_States { ... ... protected $field_tips = array(); //Add a variable to collect all the field tips ... ... /** * //Add up a function additional to set field tips * Sets tips to the given field that will be displayed to the right of the field * @param string $field * @param string $mask */ public function field_tip($field , $tip) { $this->field_tips[$field] = $tip; return $this; } ... ... ... //Then some place below in showAddForm ... protected function showAddForm() { .... ... $data->tips = $this->field_tips; ... ... //Then some place below in showEditForm ... protected function showEditForm($state_info) { .... ... $data->tips = $this->field_tips; ... ... //////////////////now in themes .. add.php / edit.php <?php echo $input_fields[$field->field_name]->input?> ///After the line above.. just add the following ..and thats it <?php if(array_key_exists($field->field_name, $tips)) { ?> <span class="tips"><?php echo $tips[$field->field_name]?></span> <?php } ?>
now the set a tip in the controller for any field
$crud->field_tip('icon', 'Max Allowed Size - 1 MB, Recomended Dimension - 100x100');
This is a good example as how to add your own functionality to grocery crud (mind it.. this is true only when u want to add the functionality @global level)
Happy GCing :)
Posted 11 March 2015 - 16:07 PM