Hot answers tagged

15

You can chain the attribute values of showon, using [AND], like so: showon="field1:1[AND]field2:1" Adding more fields to the chain is also allowed. On a side note, you can use an [OR] clause in the chain too, adding more complexity, for example: showon="field1:1[AND]field2:1[OR]fieldX:1" Update for Joomla 3.7: As of Joomla 3.7, you will be able to to ...


11

You can use Joomla's showon attribute in your field. Here's an exmaple: <field name="first" type="list" label="Select Something"> <option value="1">Option 1</option> <option value="2">Option 2</option> <option value="3">Option 3</option> </field> <field name="second" type="list" label="Select ...


11

The possible filters are: rules (Access Control Rules) unset (Do nothing, thus leaving the return value as null) raw (No filter) int_array (Filter the input as an array of integers) safehtml (Filter safe HTML) server_utc (Convert a date to UTC based on the server timezone offset) user_utc (Convert a date to UTC based on the user timezone offset) url (URL ...


4

According to the comments on this question, the answer is to remove filter="string" attribute from XML manifest file.


4

Use value and title (not country) in the sql. I believe your SQL should be as follows: SELECT country_3_code as value, country_name as title FROM #__mymuse_country ORDER by country See SQL form field type for other variations that might be more suitable for your need.


4

When ever in doubt about Joomla's form fields, have a look at the following directory, where you will find each one. libraries/joomla/form/fields To get a range form field, you can use the following: <field name="range" type="range" default="1" label="Choose a number" description="" min="1" max="10" step="1" /&...


4

Set a comma separated property "checked" in the XML file rather than using default and you should be good. We also do not call trim on the comma separated values as having spaces in values is allowed by the W3C spec. So ensure there are no surplus spaces :)


4

You can use JSON format in the controller directly by adding .json suffix and changing format in your URL to json. In this case the controller would be placed in /administrator/components/com_example/controllers/ajax.json.php. It's contents: defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Response\JsonResponse; class ExampleControllerAjax ...


3

how can I access these fields in my loadFormData() function? Actually loadFormData() is used to get the data for the form, but not the form by itself. Why do you need access your custom fields in this method? how can I modify the values of the custom fields before saving? I want to convert them to JSON format to store in a database field. At the top of ...


3

I would guess there's an implicit timezone conversion happening. It's saving the time as midnight GMT in the DB, but on re-display, it's converting it to local time.


3

There's nothing wrong in your code, rather your table definition. Max range of INT in MySQL is: -2147483648 to 2147483647 So instead of using INT for your table field, use BIGINT More details about integer data types can be found here: https://dev.mysql.com/doc/refman/5.1/en/integer-types.html


3

When using the above command to retrieve server request data, the form fields are organized in a key/value array. Which fieldset is irrelevant to retrieving the data from the array, simply use the form field name given in the XML form definition file. So, if you had a field called 'first_name' you would access like so regardless of which fieldset: $data = ...


3

This component is developed using Akeeba FOF, so you need to read the documentation to know how to complete the task. Almost everything is configured using XML, this is to some extent of course. To add the onchange javascript code to the dropdown list: https://github.com/akeeba/fof/wiki/XML-Form-Fields#additional-attributes-for-drop-down-list-fields Also, ...


2

Try adding filter="raw" to your XML file: <fields name="params"> <fieldset name="basic"> <field name="html_code" type="textarea" rows="10" cols="30" filter="raw" /> </fieldset> </fields> filter (optional) allow the system to save certain html tags or raw data. (from https://docs.joomla.org/...


2

The easiest way is to use the $_POST inside your field class like: $input = JFactory::getApplication()->input; See the reference for JInput. Though it feels like a bad design I do not see any other option how to pass the data there. Also you can access the data of your current form in your field class like this: $formData = $this->form->getData(...


2

It should work as long as your form is generated using JForm. If you build your HTML for the form yourself, then you may have to manually add the needed code and markup. Try rendering the field using <?php echo $this->form->renderField('title'); ?> or in case of the foreach you could use <?php echo $this->form->renderField($field->...


2

I guess it's a problem related to system core, Your template/Joomla don't load JS for that functionality, just add JS /media/jui/js/cms.js in your controller where you load form. regards


2

You probably forgot to specify container of the form fields. Your code should be something like $this->form->getValue('fallBeginning', 'container') if your field has actual html code like <input type="text" name="container[fallBeginning]" value="x"> The container value depends on your xml definition, what is the name of fields. For example &...


2

Glad you like it. If you just need the value, then use the field model as you can see here https://github.com/Digital-Peak/DPFields/blob/master/com_dpfields/admin/helpers/dpfields.php#L137. Keep in mind that the value is then not prepared. If the onContentPrepare event is fired on the article, then the fields are already attached to the item(article).


2

The answer was given on the forum: https://forum.joomla.org/ by user effrit. You need to create a layout override for the field. Go to Extensions => Templates => Templates. Select [YOUR-TEMPLATE] - Details and Files. Click on Create override and select Layouts => com_fields => fields. That will copy the com_field render.php into override directory of a ...


1

The problem is likely in your view. What do you get when you print something like the following in your view? <?php echo $this->form->getLabel('view_access'); ?>


1

It worked after I uninstalled and reinstalled the component. So apparently there's nothing wrong with the code.


1

Don't mess directly with the table! Use the field model which has a setValue function. It allows you to write the value correctly into the database as done in the system plugin.


1

First, you'll need to create a separate field for the alt tag. Make a note of this and the image field's ID. You then need to override the article layout. To do this, copy components\com_content\views\article\tmpl\default.php to templates\yourtemplate\html\com_content\article\default.php (where 'yourtemplate' is the name of the template you are using). ...


1

There is no standard form field type for star rating. However, you can decorate a standard form field look like star rating. For example, the below jQuery library can generate star rating using standard HTML textbox field. http://dobtco.github.io/starrr/ You can develop your own custom field if you want pure Joomla form field. See the documentation below. ...


1

Make the checkbox a radio button instead of checkbox, make the radio button required, and then follow this guide to make it look the radio button look like a checkbox.


1

I haven't looked too much into multiple="true" but an alternative could be using a text box and separating each value with a comma, like so: <field name="allowedfiletypes" type="text" label="COM_BESTIA_FIELD_ALLOWEDFILETYPES" description="COM_BESTIA_FIELD_ALLOWEDFILETYPES_DESC" default="png,jpg,jpeg,gif,pdf,zip" /> You ...


1

I see a lot of weird answers with regular expressions and attribute handling... Why? Joomla! has a great API in JForm to do everything you need. Since it's not quite clear what you want to accomplish I'll give you three alternatives for doing things the Joomla! Way. If you want to remove a specific field from a form it's easy to do it if you know the name ...


1

Add multiple="true" in field xml <field name="language" type="language" class="hidden" multiple="true" ...>


1

You should create a field element on the fly if the data for that element exists. For example: if (isset($data->someField) && !empty($data->someField)) { $element = new SimpleXMLElement( '<field name="someField" type="text" label="Label" description="Description" />' ...


Only top voted, non community-wiki answers of a minimum length are eligible