Custom field options highlighting issues

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
alexb_f
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Jan 15, 2015 4:22 pm

Custom field options highlighting issues

Post by alexb_f » Thu Jan 15, 2015 4:41 pm

So, I have my

Code: Select all

#__component_shows_exhibitors
,

Code: Select all

#__component_shows_categories
and

Code: Select all

#__component_shows_exhibitor_categories
which will contain the categories assigned to each exhibitor, therefor the table structure is the following: id, exhibitor_id and category_id

Now, I've manage to save the categories assigned to each exhibitor, with the following code, inside my exhibitor model (suggestions accepted):

Code: Select all

public function save($data)
{
    if (!parent::save($data)) {
        return false;
    }

    if (isset($data['categories'])) {
        $exhibitor_id = $data['id'];

        foreach ($data['categories'] as $category) {
            $exhibitorCategories = [
                'exhibitor_id' => $exhibitor_id,
                'category_id' => $category,
            ];

            $db = JFactory::getDbo();
            $query = $db->getQuery(true);

            $query->select($db->quoteName(array('exhibitor_id', 'category_id')));
            $query->from($db->quoteName('#__component_shows_exhibitor_categories'));
            $conditions = array(
                $db->quoteName('exhibitor_id') . "= $exhibitor_id",
                $db->quoteName('category_id') . "= $category",
            );
            $query->where($conditions);

            $db->setQuery($query);

            if (!$db->loadObjectList()) {
                $table = $this->getTable('ExhibitorCategories');

                if (!$table->bind($exhibitorCategories))
                {
                    $this->setError($table->getError());
                    return false;
                }

                if ($table->check($exhibitorCategories))
                {
                    if (!$table->store()) {
                        $this->setError($table->getError());
                        return false;
                    }
                }
                else
                {
                    $this->setError($table->getError());
                    return false;
                }
            }
        }

    }

    return true;
}

I also have the custom field called categories (options.png attachment), which works just fine, with the following code:

Code: Select all

protected function getOptions()
{
    $options = array();

    // Create a new query object.
    $db    = JFactory::getDbo();
    $query = $db->getQuery(true);

    // Select the required fields from the table.
    $query->select('id as value, name as text');
    $query->from('#__component_shows_categories');

    $db->setQuery($query);
    $options = $db->loadObjectList();

    // reset($options);

    // Check for a database error.
    if ($db->getErrorNum()) {
        JError::raiseWarning(500, $db->getErrorMsg());
    }

    return $options;
}

The only issue is that, after saving the assigned categories to each exhibitor, I get a blank input, instead of the values assigned (input.png). Any suggestions how can I work out that highlight?
You do not have the required permissions to view the files attached to this post.

alexb_f
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Jan 15, 2015 4:22 pm

Re: Custom field options highlighting issues

Post by alexb_f » Tue Jan 20, 2015 11:20 am

No ideas? :\


Locked

Return to “Joomla! 3.x Coding”