it-swarm.com.de

Die Verwendung von JHtml :: _ ('behaviour.formvalidator') in JForm gibt leere Fehlermeldungen aus

Ich benutze Joomla! 3.4 Core Form Validation und es scheint perfekt zu funktionieren, aber die der Warnung hinzugefügten Fehlermeldungen sind leer, daher kann ich nicht sehen, was der Fehler ist.

Was mache ich falsch?

Hier ist mein JForm XML-Manifest:

<?xml version="1.0" encoding="utf-8"?>
<form class="form-validate">
    <fieldset name="lead" label="Apply now!" description="Complete the form below to receive your unique code">
        <field name="name" type="text" hiddenLabel="true" class="input-block validate required" hint="Name"
               description="Your full name" label="Name" filter="string" required="true" />
        <field name="surname" type="text" hiddenLabel="true" class="input-block validate required" hint="Surname"
               description="JGLOBAL_FIELD_ID_DESC" filter="string" required="true" />
        <field name="cellphone" type="text" hiddenLabel="true" class="input-block validate required"
               hint="Cellphone number" required="true" />
        <field name="email" type="text" hiddenLabel="true" class="input-block  validate required validate-email"
               hint="Email address" filter="string" required="true" />
        <field name="membership_number" type="text" hiddenLabel="true" class="input-block validate required"
               hint="Membership number"/>
    </fieldset>
</form>

Und mein Formular-HTML wird so gerendert:

<form id="pb-apply-lead-form" action="<?php echo JRoute::_('index.php'); ?>" method="post" class="form-validate">
    <fieldset class="pb-apply-lead-fieldset">
        <?php
        # Load keep-alive, will prevent form from expiring
        JHtml::_('behavior.keepalive');
        JHtml::_('behavior.tooltip');

        if (J33)
            JHtml::_('behavior.formvalidation'); // J!3.3

        if (J34)
            JHtml::_('behavior.formvalidator'); // J!3.4

        /** @var JForm $lead_form */
        $lead_form = JForm::getInstance('lead', JPATH_COMPONENT . '/models/forms/lead.xml');
        $fieldset  = $lead_form->getFieldsets();
        ?>
        <div class="pb-title-container">
            <h3><?php echo $fieldset['lead']->label; ?></h3>
            <h4><?php echo $fieldset['lead']->description; ?></h4>
        </div>
        <div class="form-fields">
            <div class="row">
                <?php
                # Render out fieldset, use override for fields provided in layouts
                echo $lead_form->renderFieldset('lead');
                ?>
            </div>
        </div>
        <div class="form-button">
            <input type="submit" name="submit" value="<?php echo JText::_('COM_BULKBUYER_VIEW_APPLY_FORM_BUTTON_SUBMIT'); ?>" class="validate btn btn-primary"/>
            <input type="hidden" name="option" value="com_bulkbuyer"/>
            <input type="hidden" name="task" value="apply.submitlead"/>
            <input type="hidden" name="return" value="<?php echo JUri::current(); ?>"/>
            <input type="hidden" name="id" value="<?php echo $item->id; ?>"/>
            <?php echo JHtml::_('form.token'); ?>
        </div>
    </fieldset>
</form>

Vielen Dank im Voraus für jede Hilfe.

2

Das Problem ist, dass Sie die Fehlermeldungen nicht festgelegt haben, sodass keine Fehlermeldung angezeigt wird. Sie müssen enthalten:

message = "Dieses Feld ist erforderlich!"

Sie haben description = "" verwendet und dies wird in den QuickInfos des Feldes angezeigt.

So wird Ihr Code:

<?xml version="1.0" encoding="utf-8"?>
<form class="form-validate">
    <fieldset name="lead" label="Apply now!" message="Complete the form below to receive your unique code">
        <field name="name" type="text" hiddenLabel="true" class="input-block validate required" hint="Name"
               message="Your full name" label="Name" filter="string" required="true" />
        <field name="surname" type="text" hiddenLabel="true" class="input-block validate required" hint="Surname"
               message="JGLOBAL_FIELD_ID_DESC" filter="string" required="true" />
        <field name="cellphone" type="text" hiddenLabel="true" class="input-block validate required"
               hint="Cellphone number" required="true" />
        <field name="email" type="text" hiddenLabel="true" class="input-block  validate required validate-email"
               hint="Email address" filter="string" required="true" />
        <field name="membership_number" type="text" hiddenLabel="true" class="input-block validate required"
               hint="Membership number"/>
    </fieldset>
</form>

Siehe: https://docs.joomla.org/Text_form_field_type

Zur weiteren Verwendung in JForm-Textfeldern.

2
tonypartridge