How can we get a list of string into controller than show to the view in custom block
Permalink
Hi i have create a custom block
they is three input field
<input id="ccm_expandable_block_city" name="city[]" value="<?php echo $controller->city?>" maxlength="255" type="text" style="width:80%">
with the same name
how i am suppose to get a list of city inside my controller save it and show it in the view
my controller look like this
Any help would be appreciate
they is three input field
<input id="ccm_expandable_block_city" name="city[]" value="<?php echo $controller->city?>" maxlength="255" type="text" style="width:80%">
with the same name
how i am suppose to get a list of city inside my controller save it and show it in the view
my controller look like this
protected $btTable = 'btExpandable'; protected $btInterfaceWidth = "375"; protected $btInterfaceHeight = "325"; protected $btCacheBlockOutput = true; protected $btCacheBlockOutputOnPost = true; protected $btCacheBlockOutputForRegisteredUsers = true; public $country = ""; public $city = ""; public $adresse = ""; public $number = ""; public $fax = ""; public function getBlockTypeDescription() { return t("Creates a expandable block"); } public function getBlockTypeName() {
Viewing 15 lines of 38 lines. View entire code block.
Any help would be appreciate
i never manage to get a list of my city its always get the last one when i try to show it in the view
the add.php file only as 3 input with similar name but each time return the last one in the view never a list what type data should i use for db.xml im kind of confuse.
the add.php file only as 3 input with similar name but each time return the last one in the view never a list what type data should i use for db.xml im kind of confuse.
<input id="ccm_expandable_block_city" name="city" value="<?php echo $controller->city?>" maxlength="255" type="text" style="width:80%"> <input id="ccm_expandable_block_city" name="city" value="<?php echo $controller->city?>" maxlength="255" type="text" style="width:80%"> <input id="ccm_expandable_block_city" name="city" value="<?php echo $controller->city?>" maxlength="255" type="text" style="width:80%">
You can make the input name with '[]' on the end and php will take all similar and create an array.
You will then need to process that in the controller save() method to serialize it and then in the view() method to unserialize it. (or whatever method of turning an array into a string you use)
name="city[]"
You will then need to process that in the controller save() method to serialize it and then in the view() method to unserialize it. (or whatever method of turning an array into a string you use)
Thx i was able to get my list by using serialize and unserialize
Just published a howto on this as there were several similar questions.
http://www.concrete5.org/documentation/how-tos/developers/save-and-...
http://www.concrete5.org/documentation/how-tos/developers/save-and-...
Create a simple block using the designer content addon and you will see such minimal controller/edit/view files created.