Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo $this->Form->create();
- $options = array('1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10' );
- $attributes = array('legend' => false);
- ?>
- <div class="answers">
- <?php
- echo $this->Form->radio('answer1', $options, $attributes);
- ?>
- </div>
- public $validate = array(
- 'answer1' =>array(
- 'rule' => 'notEmpty',
- 'message' => 'Please choose an answer'
- )
- );
- $fields = array('answer1', 'answer2', 'answer3'); //all fields you need to validate
- foreach($fields as $field) {
- $validate[$field] = array(
- 'rule' => 'notEmpty',
- 'message' => 'Please choose an answer'
- );
- }
- public $validate = array(
- 'function' => array(
- 'allowedChoice' => array(
- 'rule' => array('inList', array('1', '2', '3', '4')) //And so on
- )
- )
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement