![]() |
XHTML Presentation of froms - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: XHTML Presentation of froms (/showthread.php?tid=5919) |
XHTML Presentation of froms - El Forum - 02-08-2008 [eluser]breaddes[/eluser] I'd like to define my formfields (including html-type and attributes) in my controller and then go through them and output them in a common from view. I have a form view that has always the same structure, only the form and the fields are different. How can I achieve that? Something with foreach? XHTML Presentation of froms - El Forum - 02-08-2008 [eluser]zwippie[/eluser] You could store all formfields in an array. Controller: Code: $data['fields']['lastname'] = '<input type="text" value="Jones">'; Code: <? foreach ($fields as $field) : ?> XHTML Presentation of froms - El Forum - 02-08-2008 [eluser]breaddes[/eluser] thanks for your reply. That's an idea, but can I combine that with the Validation or Form class? I validate those fields anyway. Of course I can now use the validation process as normal, but is there a way to combine it, to reduce code? XHTML Presentation of froms - El Forum - 02-08-2008 [eluser]Phil Sturgeon[/eluser] Code: $data['fields']['lastname'] = '<input type="text" value="Jones">'; If you are interested in setting fields too, I reccomend you set a language file with the same keynames, then do a FOREACH to loop through the rules array_keys() and grab the lang from the file and chuck it in a $fields array. XHTML Presentation of froms - El Forum - 02-08-2008 [eluser]breaddes[/eluser] Thanks, that's a great idea. XHTML Presentation of froms - El Forum - 02-08-2008 [eluser]zwippie[/eluser] edit: nvm ![]() XHTML Presentation of froms - El Forum - 02-08-2008 [eluser]Référencement Google[/eluser] [quote author="thepyromaniac" date="1202496270"]If you are interested in setting fields too, I reccomend you set a language file with the same keynames, then do a FOREACH to loop through the rules array_keys() and grab the lang from the file and chuck it in a $fields array.[/quote] I have difficulties imagining how to proceed exactly, do you have a small piece of code on how to make that exactly? XHTML Presentation of froms - El Forum - 02-11-2008 [eluser]breaddes[/eluser] ok, this is the way i am doing my form now. What do you think about it? Controller Code: $data['headline'] = $this->lang->line('centers_add'); View Code: <form action="<?=base_url().$action_url?>" id="form" method="post"> |