Пример #1
0
function SubmitSiteMap($url)
{
    $returnCode = Submit($url);
    if ($returnCode != 200) {
        echo "Error {$returnCode}: {$url} <BR/>";
    } else {
        echo "Submitted {$returnCode}: {$url} <BR/>";
    }
}
Пример #2
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.