Exemplo n.º 1
0
 * ->class('someclass'),
 * for a placeholder: ->placeholder('Some text'). If the attribute doesn't
 * take a value just omit it, so : ->required()
 *
 * In addition to HTML attributes, each element takes meta-data such as the
 * submitted value. All meta-data is set in exactly the same way but is prefixed
 * with a single underscore. For example, you can set the form's show_submitted
 * flag with ->_show_submitted(true), or force an initial check on a specific
 * item in a radioset using ->_value('name') -- in this case you are setting up
 * the element to appear as if that value was already submitted to it.
 *
 * This is done to make form specification as terse and fluent as possible
 * -- yet still giving control where needed.
 *
 **/
$contact_form = Form('contact', './')->setRenderer($r)->onSuccess('MySuccessHandler')->novalidate()->add(Fieldset('About you...', 'about')->class('about')->add(Checkbox('control', '>Collect Personal Details', 'ok')->_ignore_parent_fields('disabled,readonly,required'))->add(Input('salutation', 'Title', 'Your title please')->autofocus()->datalist($salutations)->required())->add(Input('name', 'Your Name', 'Your name please')->autocomplete('off')->required()->validator('myNameValidator'))->add(Email('email', 'Your Email', 'Your email address')->required()->autocomplete('off'))->add(URL('url', 'Website', 'Your URL here (optional)'))->add(Hidden('secret', '123'))->add(Password('pass', 'Your Password', 'Enter a password of 10 characters or more')->required()->minlength(10, '10+ chars. please'))->add(Password('oth', 'Repeat Password', 'Enter password again')->required()->minlength(10, '10+ chars. please')->matches('pass', 'This must match what you typed in the "Your Password" field.'))->add(Tel('tel', 'Phone', 'A contact number please')->pattern('/^[\\s]*[\\+]?[0-9][-0-9]*[\\s-0-9]*[\\s]*$/', 'Enter a valid phone number. This can start with an international code like +44 if needed.'))->add(Input('human', 'Are you human?', 'No bots please')->pattern('/^yes|yep|yeah|sure am|indeed$/i', 'Some form of affirmation is needed.')->required())->add(YesNo('alive', 'Were you alive when you celebrated your last birthday?', 'Babies excluded.', 'Just yes or no please.')->required())->add(Integer('age', 'How old are you?')->value(5)->min(2)->max(10)))->add(Fieldset('Your message...')->add(TextArea('msg', 'Message', 'Your message to us')->required()->pattern('/^[^0-9]*$/', 'No numbers please!')->whitelist('great,good,fantastic,amazing')))->add(Fieldset('Legal stuff...')->add(Radios('agreement', '>Do you agree to our terms?', $conditions)->required('* Please select one of the options')->validator('myConditionValidator'))->add(Checkboxes('options', 'Additional Options...', $checkboxes)->required()->value('spam_me'))->add(MSelect('depts', 'Forward to which departments?', $departments)->required('Please choose at least one department')->value('complaints-2 , complaints-3 , sales-0')))->add(Submit('Send'))->process();
/** ==================== Custom formatters follow ====================
 *
 * These all override, or append to, some aspect of the renderer's output
 * and should allow you fine enough control over your form output not to
 * have to resort to hand-crafted HTML.
 *
 * They are all enabled by setting values on the renderer.
 * Thay are also totally option. In fact, the default output of the renderer
 * should be fine in most cases so you can probably delete all the code in
 * this part of the file.
 **/
/**
 * Controls the output that goes at the head of the form when there are any
 * invalid elements. Use this only if the renderer's default markup isn't
 * what you need.
Exemplo n.º 2
0
      else if(file_exists("./photos/".strtolower($ucitel).".gif")) $foto = "<img src=\"./photos/".strtolower($ucitel).".gif\" border=\"1\">";
      else $foto1 = "<img src=\"./photos/blank.gif\">";
      echo "<center><table border=0 cellspacing=\"10\" cellpadding=\"0\">";
      if($zaznam=MySQL_fetch_array($vystup))
      {
        if($zaznam["id"]==1) $skup = "uèitel";
        else $skup = $zaznam["skupina"];
        echo "<tr><td rowspan=2>$foto</td><td><h2>".Sestav_jmeno($zaznam["titul_pred"], $zaznam["jmeno"],
	     $zaznam["prijmeni"],$zaznam["titul_za"])."</h2></td></tr>";
        echo "<tr><td><h3>($skup)</h3></td></tr>";
       /* echo "<tr><td>Aprobace: </td><td><b>".$zaznam["aprobace"]."</b></td></tr>";*/
        echo "<tr><td>Zkratka: </td><td>".$zaznam["zkratka"]."</td></tr>";
        echo "<tr><td>Kabinet: </td><td>".$zaznam["kabinet"]."</td></tr>";
        Vynech("Vyuèuje na gymnáziu", "",$zaznam["vyuc_oa"],"");
        Vynech("Vyuèuje na jaz. ¹kole", "",$zaznam["vyuc_vose"],"");
        echo "<tr><td>©kolní telefon: </td><td>".Tel().", kl. ".$zaznam["tel1"]."</td></tr>";
        Vynech("Vlastní telefon", "",$zaznam["tel2"],"");
        Vynech("©kolní e-mail", "<a href=\"mailto:".$zaznam["mail1"].c_mail."\">", $zaznam["mail1"], c_mail."</a>");
        Vynech("Vlastní e-mail", "<a href=\"mailto:",$zaznam["mail2"],"\">".$zaznam["mail2"]."</a>");
        Vynech("URL", "<a href=\"".$zaznam["url"]."\">",$zaznam["url"],"</a>");
 /*       echo "<tr><td colspan=2>";
	Vyber_klic($klic, "Zobrazit odeslané vzkazy",
                   "Zobrazit odeslané soubory");
	echo "</td></tr>";                      */
      }
      echo "</table>";
      echo "<p>&nbsp;</p>";
      /*switch($klic)
      {
        case 1: Vzkazy($ucitel);
        break;