Thanks for your replies both!
I'm using Symfony 1.2.
I considered doing it in the actions.class.php, but this _always_ has
to be done by submitting the form. Both on the new action and the edit
action. So I prefer doing it in the form class.
Marijn, what exactly is the updateObject() function? It sounds like
that function is only used if the form is executed from the edit
action.
I already tried this with the doSave() function, but that goes wrong
in the last line before the die() function:
public function doSave($con = null){
$aRelations = $this->getValue('link_page_keyword_list');
$aKeywords = array();
$aValues = explode(';', $this->getValue('keywords'));
foreach($aValues as $sKeyword){
$sKeyword = eregi_replace('[[:punct:]]|[[:cntrl:]]|^ +|
+$', '',
$sKeyword);
if($sKeyword != ''){
$oKeyword =
KeywordPeer::retrieveByTitle($sKeyword);
if(!$oKeyword){
$oKeyword = new Keyword();
$oKeyword->setTitle($sKeyword);
$oKeyword->save();
}
if(!in_array($oKeyword->getId(), $aRelations))
$aRelations[] =
$oKeyword->getId();
}
}
$this['link_page_keyword_list'] = $aRelations;
// Latter code is where it goes wrong, unable to add values it
says.
die(print_r($this->getValue('link_page_keyword_list')));
parent::doSave();
}
On 11 mrt, 09:27, Marijn <[email protected]> wrote:
> I would suggest you override the updateObject method of your form.
> Proof of concept:
>
> public function updateObject ()
> {
> parent::updateObject();
> if ($this->isValid())
> {
> $this->values['my_custom_added_value'] = 'MyCustomAddedValue';
> }
>
> }
>
> What version of symfony are you using? You need to check the form
> class to see what the method signature is for the version you are
> using cause that has changed from 1.1 to 1.2.
>
> Good luck,
>
> Marijn
>
> On Mar 10, 5:58 pm, HAUSa <[email protected]>
> wrote:
>
> > I got a form, in which users can select multiple values for a field
> > using sfWidgetFormChoiceMany().
>
> > Now, is it possible to add more values to the submitted array on
> > submit? I'm not talking about default values when the form shows, but
> > specifically when the form gets submitted. So the default values are
> > added afterwards.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---