Reputation: 146302
I have the following code:
<h2>Add System</h2>
<?php
echo $this->Form->create('ReleaseServer');
echo $this->Form->input('server_name',array('error'=>array(
0 => 'Please choose a system name'),
'label'=>'System Name'
));
echo $this->Form->input('server_id', array('label'=> 'System ID'));
echo $this->Form->select('server_environment', $environments, null, array(
'empty' => "-- Select an Environment --",
'label' => "Select an Environment",
'error' => array(0 => 'Please choose an environment!'),
'onchange'=>'console.log(this.value);'
)
);
echo $this->Form->end('Save System');
?>
For some reason the line
echo $this->Form->input('server_id', array('label'=> 'System ID'));
shows up as a select box no matter where I place it.
How do I resolve this?
Upvotes: 0
Views: 214
Reputation: 7853
You could try adding type
to your options array and explicitly defining what you want the input to be.
Edit
After digging around in the Cake API I think I may have found a specific line of code that may be affecting you here.
if (preg_match('/_id$/', $fieldKey) && $options['type'] !== 'hidden') {
$options['type'] = 'select';
}
It appears likely that you are triggering this if
conditional. If so, your only option is to explicitly set the type
attribute in your options array.
Upvotes: 1
Reputation: 2985
Just hide the input if it doesn't matter to show or not. As when inserting mysql will assign it a new id.
echo $this->Form->input('server_id', array('type'=> 'hidden'));
Upvotes: 0
Reputation: 146302
Right now I am using a hack:
echo $this->Form->input('server_id', array('label'=> 'System ID',
'type'=>'text'));
I am explicitly setting the type
as text.
I do not have to do that for the other input, but that might be the way it has to be.
Upvotes: 0