0
votes

I am new at cakephp 1.3. I am trying to create an Edit User Form with Form Helper in Cakephp 1.3.

I am unable to customize the alignments of the form elements, for example:

echo $this->Form->create('Model', array('action' => 'edit_users','id' => 'UserForm'));
echo $this->Form->input('First Name',array('style'=>'width:100px','label'=>'First Name:'));
echo $this->Form->input('Last Name',array('style'=>'width:100px','label'=>'Last Name:'));
echo $this->Form->input('Position',array('style'=>'width:100px','label'=>'Position:'));

I want the first two input fields on a single line and the third input field on the second line. I have tried it with div false, but its not working. How can I achieve this?

2

2 Answers

1
votes

div=>false works but you will need to add some css

echo $this->Form->create('Model', array('action' => 'edit_users','id' => 'UserForm'));
echo '<div id="first">';
    echo '<div class="leftalign">';
      echo $this->Form->input('First Name',array('div'=>false,'label'=>'First Name:'));
    echo '</div>';
echo '<div class="rightalign">';
echo $this->Form->input('Last Name',array('div'=>false,'label'=>'Last Name:'));
    echo '</div>';
echo $this->Form->input('Position',array('style'=>'width:100px','label'=>'Position:'));

CSS

#first .leftalign{
    float: left;
     width:300px;
 }
 #first .rightalign{
     clear:none;
     float: right;
     width:300px;
 }
 #first label,#first input{
  width: 100px;
 } 

You can edit the css as per your requirements

0
votes

this one worked for me

<table border='0'>
     <tr><td>
            <?php echo $this->Form->create('Model', array('action' => 'edit_users','id' => 'UserForm'));
                  echo $this->Form->input('First Name',array('label'=>'First Name:'));?>
         </td><td>                     
            <?php echo $this->Form->input('Last Name',array('label'=>'Last Name:'));?></td>
     </tr>
    <tr><td>
            <?php echo $this->Form->input('Position',array('label'=>'Position:'));?>
         </td>
</table>

Just put your form controls in a table and you can align them on the form any how you want!