Input Value Retention with Attribute Render versus Form Helper

Permalink 1 user found helpful
Concrete5 has the great form helper which will retain a users selections and inputs when a form is submitted to the containing page and the page is re-rendered.

Sometimes it's imperative that I use an attributes render function instead, that way if a user adds his own select options, etc.. any forms the attribute is being shown on will automatically update.

Is there a simple way of retaining the values when using the $akt->render() function versus the $form->select() function?

At this point I am going to have to load up the attribute and cycle through all the available options building the form helper attributes manually.

Am I missing a better way?

guythomas
 
guythomas replied on at Permalink Reply
guythomas
For Reference, here is what I am doing now..

In the Controller:

public function on_page_view() {
$ak = CollectionAttributeKey::getByHandle('location');
$nb = AttributeType::getByHandle('select')->getController();
$nb->setAttributeKey($ak);
$options = $nb->getOptions();
foreach($options as $opt) { 
   $loc_opt_array[$opt->getSelectAttributeOptionID()] =$opt->getSelectAttributeOptionValue();
}
$this->set('loc_opt_array', $loc_opt_array);
}


further down in my form processing area of the controller

if ($this->isPost()) {
$tvalue = $this->post('location');
$this->set('tvalue', $tvalue);
}


In the view I am rendering it like so:

print $form->select('location', $loc_opt_array, $tvalue);