Monday, May 18, 2015

Form width fieldset and different button types

Hi there!

I'm trying to use the jquery file uploader in combination with CakePHP.

The HTML form uses 3 different button types:
  • submit (<button type="submit">Start upload</submit>)
  • reset (<button type="reset">Start upload</submit>)
  • button (<button type="button">Start upload</submit>)
With CakePHP, I try to create those buttons via $this->Form->inputs, but I don't find out how I should sum up those different type of inputs.

I tried the following, but it ends up that those buttons are becoming input fields instead:

echo $this->Form->create('OutletPhoto', array(
   
'type' => 'file',
   
'novalidate' => true, // browser validatie
   
'inputDefaults' => array(
       
'label' => true,
       
'div' => 'form-group',
       
'class' => 'form-control'
   
),
   
'role' => 'form'
));

echo $this
->Form->inputs(array(
   
'legend' => false,
   
'name' => array(
       
'type' => 'file',
       
'multiple',
       
'label' => false,
       
'id' => 'file_upload',
       
'name' => 'file_upload',
       
'class' => false,
       
'before' => 'Pick photos',
       
'after' => '
'
   
),
   
'Start upload' => array(
       
'type' => 'submit',
       
'label' => false,
       
'class' => 'btn btn-primary start'
   
),
   
'Cancel upload' => array(
       
'type' => 'reset',
       
'label' => false,
       
'class' => 'btn btn-warning cancel'
   
),
   
'Delete' => array(
       
'type' => 'button',
       
'label' => false,
       
'class' => 'btn btn-danger delete'
   
)
));

echo $this
->Form->end('Save');

Here's the HTML output of this code:

<div class="form-group"><div class="submit"><input class="btn btn-primary start" type="submit" value="Start upload"></div></div>
<div class="form-group"><input name="data[OutletPhoto][Cancel upload]" class="btn btn-warning cancel" type="reset" id="OutletPhotoAnnuleerUpload"></div>
<div class="form-group"><button class="btn btn-danger delete" type="submit">Delete</button></div>

Anyone who can tell me why my Start upload and Cancel upload don't show up as a button? Thanks in advance! ;)

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: