0

I have a weird issue.

Here is my form's xml:

<?xml version="1.0" encoding="utf-8"?>
<form>
    <fieldset name="details">
        <field name="id" type="hidden" default="" label="COM_JOMDIRECTORY_ROUTE_ID_LABEL" description="COM_JOMDIRECTORY_ROUTE_ID_DESC" readonly="true" />
        <field name="id_parent" type="text" default="" label="COM_JOMDIRECTORY_ROUTE_ID_CATEGORY_LABEL" description="COM_JOMDIRECTORY_ROUTE_ID_CATEGORY_DESC" maxlength="11" required="true" />
        <field name="category_name" type="text" default="" label="Category name" description="COM_JOMDIRECTORY_ROUTE_ID_CATEGORY_DESC" maxlength="255" required="true"/>
        <field name="published" type="radio" default="" label="COM_JOMDIRECTORY_ROUTE_PUBLISHED_LABEL" description="COM_JOMDIRECTORY_ROUTE_PUBLISHED_DESC" maxlength="4" required="true" multiple="false" >
            <option value="0">JNO</option>
            <option value="1">JYES</option>
        </field>
        <field name="created_date" type="calendar" default="0000-00-00 00:00:00" label="COM_JOMDIRECTORY_ROUTE_CREATED_DATE_LABEL" description="COM_JOMDIRECTORY_ROUTE_CREATED_DATE_DESC" maxlength="255" required="false" multiple="false" />
        <field name="modified_date" type="calendar" default="0000-00-00 00:00:00" label="COM_JOMDIRECTORY_ROUTE_MODIFIED_DATE_LABEL" description="COM_JOMDIRECTORY_ROUTE_MODIFIED_DATE_DESC" maxlength="255" required="false" multiple="false" />
    </fieldset>
    <fields name="params">
        <fieldset name="params" label="JGLOBAL_FIELDSET_DISPLAY_OPTIONS">
        </fieldset>
    </fields>
</form>

This is my form code:

<form action="<?php echo JRoute::_('index.php'); ?>" method="post" name="adminForm" id="jomdirectoryroutescategories-form">
                            <div class="control-group">
                                <div class="control-label"><?php echo  JText::_( 'COM_JOMDIRECTORY_ROUTE_ID_PARENT_CATEGORY_LABEL' ); ?></div>
                                <div class="controls">
                                    <select name="jform[id_parent]" id="jform_id_parent" required="required" aria-required="true" class="requird  chzn-done">
                                        <option value="0">Please select a category</option>
                                        <?php foreach($parent_categories as $parent_category) {
                                            if($parent_category->id == $item->id_parent)
                                            {
                                                $selected = 'selected="selected"';
                                            }
                                            else
                                            {
                                                $selected = '';
                                            }
                                        ?>
                                        <option value="<?php echo $parent_category->id;?>" <?php echo $selected;?>><?php echo $parent_category->category_name;?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                            </div>
                            <div class="control-group">
                                <div class="control-label"><?php echo  JText::_( 'Category name' ); ?><span class="star">&nbsp;*</span></div>
                                <div class="controls">
                                    <input type="text" id="jform[category_name]" name="jform_category_name" value="<?php echo $item->category_name;?>" required="required" aria-required="true">
                                </div>
                            </div>
                            <div class="control-group">
                                <div class="control-label"><?php echo  JText::_( 'COM_JOMDIRECTORY_ROUTE_PUBLISHED_LABEL' ); ?><span class="star">&nbsp;*</span></div>
                                <div class="controls">
                                    <select id="jform_published" name="jform[published]" class="required chzn-done" required="required" aria-required="true">
                                        <?php
                                            if($this->item->published == 1)
                                            {
                                                $selectedyes = 'selected="selected"';
                                            }
                                            else
                                            {
                                                $selectedno = 'selected="selected"';
                                            }
                                            ?>
                                            <option value="0" <?php echo $selectedno;?>>No</option>
                                            <option value="1" <?php echo $selectedyes;?>>Yes</option>
                                    </select>
                                </div>
                            </div>
                            <input type="hidden" name="option" value="com_jomdirectory" />
                            <input type="hidden" name="id" value="<?php echo $this->item->id; ?>" />
                            <input type="hidden" name="task" value="" />
                            <input type="hidden" name="layout" value="edit">
                            <?php echo JHtml::_('form.token'); ?>
                            </form>

The problem is that when I complete the form fully, it throws an error:

Warning

Field required: Category name

Can you see anything whether I am doing anything obviously wrong?

Edit: here is the form post:

jform[id_parent]:"0"
jform_category_name:"West+Coast"
jform[published]:"1"
option:"com_jomdirectory"
id:"1"
task:"routecategory.apply"
layout:"edit"
18c9ffe9455727e6212fac5ac6414b7d:"1"

EDIT: I found the issue, and the cause was that I am a dumbass. I had the field's id value and name value swapped around with each other.

Thanks for looking.

  • The warning says that the category name field is required and it actually is defined like that. Aren't you submitting a category name, or you do and it doesn't submit its value? – FFrewin Dec 3 '15 at 6:51
  • @FFrewin I am submitting a value, but it is almost as if I am not. – Jacques Dec 3 '15 at 6:54
  • I am updating my question with the form post – Jacques Dec 3 '15 at 6:56
  • Solved: I had the field id and field name swapped. – Jacques Dec 3 '15 at 6:59
  • 3
    then consider to write the answer and accept it. – FFrewin Dec 3 '15 at 8:43

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.