

How to add radiobutton/radiobutton with custom value
#1
Posted 29 May 2012 - 11:21 AM
I am very much impressed with your tool.
I am yet to see some examples using radiobutton or dropdown boxes which are missing. Is there any tutorial for that?
Say for example.. I have a gender column in database table which expects values Male | Female (values are custom)
How do you implement this?
Also if I want to display it as a dropdownbox also.. Pls provide me sample codes for radiobutton and dropdown box.
Thanks,
Demis John
#2
Posted 29 May 2012 - 12:52 PM
i dunno about radio button if it can be directly render like that of dropdown for enum data types... but you can use callback_add_field function to add radio button.. i hope it may work for you
function example_callback_add_field(){ $crud = new grocery_CRUD(); $crud->set_table('offices'); $crud->set_subject('Office'); $crud->required_fields('city'); $crud->columns('city','country','gender','addressLine1','postalCode'); $crud->callback_add_field('gender',array($this,'add_field_callback_1')); $output = $crud->render(); $this->_example_output($output); } function add_field_callback_1() { return ' <input type="radio" name="sex" value="male" /> Male <input type="radio" name="sex" value="female" /> Female'; }
#3
Posted 29 May 2012 - 01:03 PM
#4
Posted 29 May 2012 - 04:34 PM
#5
Posted 29 May 2012 - 04:40 PM
#6
Posted 29 May 2012 - 05:28 PM
Another simple possibility for radio buttons is to use:
$crud->change_field_type('your_field','true_false');The only problem here is you are stuck with the default button labels of "active" and "inactive" and values of 1 and 0, respectively.
#7
Posted 28 June 2012 - 05:59 PM
#8
Posted 18 March 2013 - 08:04 PM
You can change the values of radio buttons in the config file for your language. for english, it's here:
assets\grocery_crud\languages\english.php
Just change these 2 lines:
#9
Posted 17 September 2013 - 11:43 AM
Hello
I have wanted to know how to make the checkbox is the value of the db. Otherwise, when the checkbox is edict are always equal to 0 even if the value is 1
#10
Posted 28 August 2017 - 01:16 PM
Hi I am new to grocery CRUD , I surfed on internet to find the solution for this , but I found none,
Myself found one solution for radio button edit , Hope this helps
$crud->change_field_type('government','true_false');
// This part is for inserting, 'government' is the name of the field or column name in the database table.
// now This part is for update or edit
$crud->callback_edit_field('government',array($this,'radio_edit_callback'));
//Function for the callback_edit_field
public function radio_edit_callback($value) { //$value will be having the present value(Y or N) that is in the list or database.
#11
Posted 28 August 2017 - 03:14 PM
#12
Posted 29 August 2017 - 04:48 AM
Inspect in developer tools (Chrome / firefox) .. check the value of the field that gets submitted back. Is it the value that goes as expected or what.. if not, then u need to re-work on the form generation (Field alteration) where your value is getting passed on.
#13
Posted 29 August 2017 - 06:57 AM
Thanks for the tip Mr. Amit shah , I found the solution to that problem, there was spaces between the double quotes (value=" '.$value.' ") that is the reason , The value was passing (one space) instead of the $value(Y or N), Now its working all good . I corrected the above code as value="'.$value.'" (There should be no space between the double quotes and single quote).
Thank you Once again.
Also tagged with one or more of these keywords: radiobutton, dropdown
Support →
Grocery CRUD Enterprise →
Problem with the setRelation dropdown.Started by dhouwen, 04 Feb 2020 ![]() |
|
![]() |
||
Support →
Grocery CRUD Enterprise →
Disable dropdown in search filters and change to text inputStarted by Indeax, 26 Nov 2018 ![]() |
|
![]() |
||
Support →
Grocery CRUD Enterprise →
Bug v2.6.8: Custom dropdown field not working with callbackColumnStarted by jw_hultafors, 05 Nov 2018 ![]() |
|
![]() |
||
Support →
Grocery CRUD Enterprise →
Dropdown Set Value On FieldStarted by nungadi28, 19 Apr 2018 ![]() |
|
![]() |
||
Support →
I have a question →
setRelation Dropdown option with attributeStarted by farazu101, 22 Mar 2018 ![]() |
|
![]() |
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users