21
votes
Accepted
What are possible filters in Joomla form fields?
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 ...
8
votes
Accepted
JForm showon attribute does not work in admin site
Found what the issue is. I was using getInput function to show the field.
$this->form->getInput('field2');
but showon attribute working only if I render the field using renderField function
$...
7
votes
Accepted
How to show a search box inside a list form field
You need to load chosen plugin to style list box fields like this.
Load chosen plugin first in your form layout file so that it can add style to your select boxes
JHtml::_('formbehavior.chosen', '...
7
votes
Accepted
How to get module parameters inside helper function and how to get params inside a custom form field type?
1. How to get Modules parameters inside Helper Function
You are going all wrong with this.
First, you can't use $this inside a static method, because they are independent of any instantiated object. ...
7
votes
How to get module parameters inside helper function and how to get params inside a custom form field type?
I much prefer going for the OOP approach. This is what I use in one of my extensions. It's Ajax based so I have a separate function to get the parameters.
helper.php:
class ModSomethingHelper
{
...
6
votes
Accepted
Overriding Core Components Model Form XML
The more standard approach would probably be to use a plugin to catch the JForm object after the XML has been processed but before it has left the model to make your changes. An example of that ...
5
votes
Accepted
How to style a Custom Field radio list as btn-group?
Having looked at the JHtml radiolist function, it does not support custom classes. It manually adds the radio class via the actual core file.
What I've done here is taken a copy of the core radio ...
5
votes
Filtering list of Users in User form field type
In fact, it is very easy to filtering the list of users in User form field type.
First in your manifest you should create a new type for your field, for example userFiltering (see below)
<field
...
5
votes
Accepted
How to retrieve values of all the fields with JInput but without jform[]
Yes, you can get the form values without jform. Following is the approach:
$data = $jinput->post : returns all post data
$something = $jinput->post->get('something', 'default_value', '...
4
votes
Accepted
How to get the form of component from module?
Try to add an additional path where to look for forms before your call to $model->get('Form').
JForm::addFormPath(YOUR_COMPONENT_FORMS_PATH);
You will need it because getForm calls loadForm (...
4
votes
Accepted
Filtering list of Users in User form field type
You could simply use
<field name="modified_user_id"
type="user"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
desc="A_DESCRIPTION_IS_ALWAYS_GOOD"/>
It creates a modal field that display a ...
4
votes
Accepted
Writing custom method to save form data
Initially I figured the best would be to use the controller method save(), which I finally got working like this:
$path = JPATH_ADMINISTRATOR . '/components/com_anycomponent;
JLoader::register('...
4
votes
Accepted
Server-side validation rule is not being found
It seems that you actually have to specify what the path is for and put it in the right place, lol! The problem was in specifying a path for the fields instead of for the rules!
This correction ...
4
votes
Accepted
How to work with field type Checkboxes (not checkbox)
My first offering, so please don't shoot me. I've been fighting this one for a while and FINALLY found a solution that works well. Hoping to help others avoid this nightmare.
The key piece I was ...
4
votes
Joomla 3 Flexicontent custom form based on jForm
Both cited articles refer to Joomla content manager.
Even though Flexicontent extends, onContentPrepareForm is not being called or rendered in your Flexicontent configuration.
I suggest to test the ...
4
votes
Accepted
How can I dynamically generate a form's XML from PHP?
I was working with jForm and methods setField() and getFieldset() to set and retrieve the fields, but Joomla was throwing errors. While trying to add a list Joomla was unable to parse the XML until I ...
4
votes
Accepted
How to add jQuery functionality in the backend of a module?
You will need to create a custom form field for this.
So firstly, change the type of the field in your XML like so:
<field name="brands" type="brands" label="Foreign Brands" />
Then in your ...
4
votes
Accepted
Custom XML attributes not showing in HTML markup
Though the XML file and the rendered HTML both call them attributes, there is not a direct pass through of values. Hence, only some attributes make it to the HTML (and some extra attributes are added)....
4
votes
Accepted
Array of form fields
I manged to get a solution as below.
<field name="gralev_code][]"
type="text"
class="width20"
label="JSCH_GRALEV_CODE"
/>
in model.php
$formdata = $this->_jinput->get('jform', '...
4
votes
Accepted
Building Component - Replace "Invalid Field: My Field" with Custom Message
Well fortunately, I got my server side validation working by this way:
use Joomla\Registry\Registry;
JFormHelper::loadRuleClass('email');
class JFormRuleValidemail extends JFormRuleEmail {
...
4
votes
Accepted
Load a Single Admin view with multiple tables and forms
In your model class you want to override the getItem method like so:
public function getItem() {
$item = parent::getItem();
$item->second_table = $this->getSecondTable($item->...
4
votes
Adding Custom Fields to Article Component [Not in attribs field]
I've been using FieldsAttach for this sort of thing, for a few years, the the concepts are clean and eloquent. Brian Teeman explains it well from an integrator point of view in his talk at https://www....
4
votes
How to get module parameters inside helper function and how to get params inside a custom form field type?
Your main module file and template file will have $params variable created by Joomla! core.
If you have static methods, then pass that variable to function call:
class ModTestHelper
{
public ...
4
votes
How to use a custom layout with JForm subform fields?
Edited to add subform field type-specific answer:
Having looked at it properly, attaching your own layout to the subform field type is super-easy.
Create a layouts folder in the same parent ...
3
votes
Accepted
Store multiple form fields as JSON string
You can do it either in your Table class or Model class:
// Convert a JSON field to an array
$registry = new JRegistry;
$registry->loadString($item->jsonfield);
$item->jsonfield = $registry-&...
3
votes
How to work with field type Checkboxes (not checkbox)
Seems to me you want to save all the results as an array, and then save that array as JSON in a single field.
Example of field.. look at your database, #__content table, see the attribs field for ...
3
votes
Accepted
How can I provide a custom message for a failed JFormRule validation?
Add the message attribute, but better like this:
<field name="my_code" type="text" size="15" label="My Code"
validate="myrule" message="Field may only contain A-z or 0-9" />
:)
3
votes
How to save data from 2 fields as a JSON string to 1 database table field?
You need both PHP functions to do this work:
json_encode :
http://www.php.net/manual/de/function.json-encode.php
json_decode:
http://www.php.net/manual/de/function.json-decode.php
Maybe something ...
3
votes
Accepted
How can I override the class or readonly attribute that is specified in the form xml?
Yes you can do this.
We have a component that has a concept of "Plans", it uses the same view for different access levels, but makes the fields accessible or not depending on the users groups.
So ...
3
votes
How to access a specific fieldset in a form in my model class?
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
jform × 125joomla-3.x × 52
form-fields-types × 15
component × 13
custom-field × 13
form × 13
joomla-3.4 × 11
fields × 11
model × 11
custom-component × 9
xml × 8
development × 7
joomla-2.5 × 6
plugin × 6
javascript × 6
validations × 6
php × 5
module × 4
jquery × 4
ajax × 4
filter × 4
joomla-4.x × 3
jinput × 3
controller × 3
validation × 3