I've made complex form which is valid in action. I'd like to get value from this input to save file on server.
<input type="text"
name="produkty[pForm][1][caption]"
id="produkty_pForm_1_caption" />
I've tried something like that:
$this->form=new ProduktyForm();
if ($request->isMethod(sfRequest::POST))
{
$this->form->bind($request->getParameter('produkty'),$request->getFiles('produkty'));
if ( $this->form->isValid())
{
$file=$this->form->getValue('produkty[pForm][1][src]');
$filename='u';
$extension = $file->getExtension($file->getOriginalExtension());
$file->save(sfConfig::get('sf_upload_dir').'/'.$filename.$extension);
}
}
But it doesn't work.
'produkty' is the name of your form. Are you using a subform to capture an array of possible files to be input?
You could get the values of the entire form by doing this.
$form_vals = $this->form->getValues();
Then you could could see what variables you have by your output.
You'll probably be able to get the input this way.
$caption = $form_vals['pForm'][1]['caption'];
this is working fine but how to fetch the values from file attributes . i cant get the values from file input my main form name is slide and subform is mslide
here is the my code
$this->multiSlideForm->bind($request->getParameter('slide'), $request->getFiles('slide'));
$form_vals = $this->multiSlideForm->getValues();
echo $form_vals['mslide'][0]['slide_name']; //working
echo $this->multiSlideForm->getValue('[mslide][0][file_name]')->getOriginalName(); //not working
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.