Problem pri setValue. Prvky formulare se nenaplni pomoci funkce setValue

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
blueticket
Člen | 41
+
0
-

Zdravim vas, v nette jsem novej a celkem nevim, jak vyresit muj problem.

Mam v sablone .latte nadefinovanej nasledovnej formular:

{form frmSignIn}
    <input type="hidden" name="formName" value="frmSignIn" />
    <div class="form-group">
        <input type="text" class="form-control required" id="txtName" name="txtName" placeholder="{_'Name'}" data-error="Vyplne meno" required>
        <div class="help-block with-errors error-message"></div>
    </div>
    <div class="form-group">
        <input type="text" class="form-control required" id="txtSurname" name="txtSurname" placeholder="{_ 'Surname'}" required>
        <div class="help-block with-errors error-message"></div>
    </div>
    <div class="form-group">
        <input type="email" class="form-control required" id="txtEmail" name="txtEmail" placeholder="{_ 'Email'}" required>
        <div class="help-block with-errors error-message"></div>
    </div>
    <div class="form-group">
        <input type="hidden" id="hidddlCountries" name="hidddlCountries" />
        <select class="form-control font_size_13px required" id="ddlCountries" name="ddlCountries" required>
            <option value="">{_"Please select state"}...</option>
            {foreach $states as $state}
                <option value="{$state->CountryName_en}">{_$state->CountryName_en}</option>
            {/foreach}
        </select>
        <script type="text/javascript">
            $("#ddlCountries").on("change", function () {
                $("#hidddlCountries").val($("#ddlCountries").val());
            });
        </script>
        <div class="help-block with-errors error-message"></div>
    </div>
    <div class="form-group">
        <input type="password" class="form-control required" id="txtPassword" name="txtPassword" placeholder="{_ 'Password'}" required>
        <div class="help-block with-errors error-message"></div>
    </div>
    <div class="form-group">
        <input type="password" class="form-control required" id="txtConfirmPassword" name="txtConfirmPassword" data-match="#txtPassword" data-match-error="Whoops, these don't match" placeholder="{_ 'Confirm password'}" required>
        <div class="help-block with-errors error-message"></div>
    </div>
    <div class="form-group" style="font-size:12px;color:white;">
        By clicking Register, you agree to our <a n:href="pages:general_terms" style="color:#FDB42F;text-decoration: underline;" target="_blank" rel="nofollow">Terms</a> and you have read our <a n:href="pages:cookies_use" style="color:#FDB42F;text-decoration: underline;" target="_blank" rel="nofollow">Cookie Use</a>.
    </div>
    <button type="submit" id="btnSignIn" name="btnSignIn" class="btn btn-danger btn-block"><i class="fa fa-unlock-alt"></i>&nbsp;&nbsp;{_ 'Register'}</button>
{/form}

a pote kdyz chci naplnit textfield-y v sablone z php kodu pomoci nasledovny funkce, tak mi to nic neudela a textfield-y zustanou prazdne:

protected function createComponentFrmSignIn() {
    $form = new Form();
    $form->addText("txtName")->setValue("Radoslav");
    $form->addText("txtSurname")->setValue("Mihalus");
    $form->addText("txtEmail")->setValue("BlaBla");
    $form->addText("hidddlCountries");
    $form->addPassword("txtPassword");
    $form->addPassword("txtConfirmPassword");
    $form->addSubmit('btnSignIn', 'Register')->onClick[] = array($this, 'frmSignInSucceeded');
    return $form;
}

Nikde jsem se nedocetl, jak definovat (designovat) formular v .latte a pote s nim pracovat v presenteru.

Dekuji za radu, co delam spatne

David Matějka
Moderator | 6445
+
+1
-

Musis pouzit makra input nebo n:name, viz doc: https://doc.nette.org/cs/forms#…

blueticket
Člen | 41
+
0
-

Cili by stacilo zmenit atribut name na n:name?

David Matějka
Moderator | 6445
+
0
-

jj melo by to stacit. A pak muzes smazat atributy jako type, required atd., ktere nette take doplni (treba required v pripade, ze mas u inputu setRequired)

blueticket
Člen | 41
+
0
-

Super!!! Funguje!!! Dekuju moc!!!