Overview

Namespaces

  • None
  • PHP
  • Pry
    • Auth
      • Interfaces
    • Config
    • Controller
    • Date
    • Db
    • Feed
      • Abstracts
      • Writers
    • File
      • Decorator
    • Form
      • Element
    • Image
    • Log
      • Writer
    • Net
      • Exception
    • Session
    • Util
    • Validate
      • Validator
    • View

Classes

  • AutoCompleter
  • Checkbox
  • Colorpicker
  • Date
  • DatePicker
  • Email
  • File
  • Hidden
  • Html
  • Ip
  • Mac
  • Multi
  • NumericStepper
  • Password
  • Radio
  • Select
  • Slider
  • Submit
  • Text
  • Textarea
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: /**
 4:  * Pry Framework
 5:  *
 6:  * LICENSE
 7:  *
 8:  * This source file is subject to the new BSD license that is bundled
 9:  * with this package in the file LICENSE.txt.
10:  * 
11:  */
12: 
13: namespace Pry\Form\Element;
14: 
15: /**
16:  * Element Radio
17:  * @category Pry
18:  * @package Form
19:  * @subpackage Form_Element
20:  * @version 1.0.6 
21:  * @author Olivier ROGER <oroger.fr>
22:  */
23: class Radio extends Multi
24: {
25: 
26:     /**
27:      * Constructeur
28:      *
29:      * @param string $nom
30:      * @param Form_Form $form
31:      * @access public
32:      */
33:     public function __construct($nom, $form)
34:     {
35:         parent::__construct($nom, $form);
36:         $this->attrs['type'] = 'radio';
37:     }
38: 
39:     /**
40:      * Affiche les boutons radios
41:      * @access public
42:      * @return string
43:      */
44:     public function __toString()
45:     {
46:         $css   = $this->cssClass();
47:         $label = '';
48:         if (!empty($this->label))
49:         {
50:             $label = "\t" . '<span class="' . $this->cssLabel . '">' . $this->label . '</span>' . "\n";
51:             if (!empty($this->info))
52:                 $label.="\t" . '<img src="' . $this->imgInfo . '" id="' . $this->attrs['name'] . '_tooltip" class="form_tooltip" title="' . $this->info . '" alt="" style="cursor:help;" />';
53:             if ($this->labelNewLine)
54:                 $label.="\t" . '<br />' . "\n";
55:         }
56: 
57:         $field     = '';
58:         $attributs = $this->attrsToString();
59:         //Posted value ou value par défaut
60:         $value     = $this->form->getPostedvalue($this->attrs['name']);
61:         if ($value == '')
62:             $value     = $this->value;
63: 
64:         foreach ($this->choix as $valhtml => $valAffichee) {
65:             if ($value == $valhtml)
66:                 $checked = ' checked="checked"';
67:             else
68:                 $checked = '';
69: 
70:             $field.="\t" . '<input ' . $css . ' value="' . htmlspecialchars($valhtml) . '" ' . $attributs . $checked . ' /> ' . $valAffichee . "\n";
71:             if ($this->fieldNewLine)
72:                 $field.="\t" . '<br />' . "\n";
73:         }
74:         $error = '';
75:         if (!is_null($this->errorMsg))
76:         {
77:             $error = '<span class="' . $this->errorClass . '">' . $this->errorMsg . '</span><br />';
78:         }
79:         return $label . $field . $error;
80:     }
81: 
82: }
83: 
84: ?>
Pry API documentation generated by ApiGen 2.8.0