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
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
{
...
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. ...
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
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
Accepted
JFormFieldList in Frontend -> Notice: Array to string conversion
I think you want to use use getOptions(..) not getInput(...) with a JFormFieldList.
getInput returns the full <select /> input as a string. getOptions populates the select options with an array ...
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
Where can I find a good tutorial and/or example for creating front-end forms in custom components?
Everything you need to get started with JForm for views
https://www.ostraining.com/blog/how-tos/development/getting-started-with-jform/
3
votes
Insert value to custom field using getForm (setFieldAttribute)
Mea culpa,
I had to add the name of the group:
$form->setFieldAttribute('test', 'country', 'US', 'personal');
3
votes
Custom 'dynamic' form field creation
I am using the following to achieve something similar to what you need BUT in a plugin. Need to confirm if it is also valid to component.
<field
name="list_field_name"
...
3
votes
Accepted
Manually render filter form fields in layout
Include group name as the second parameter in renderField(), e.g.:
echo $this->filterForm->renderField('published', 'filter');
echo $this->filterForm->renderField('limit', 'list');
Or if ...
3
votes
Accepted
Client side validation - custom event handler not called when user enters the field and leaves it being empty
I deleted my earlier answer, since it was on some points true but not exactly answered the question. My mind was blurred by the question. :) The question is very tricky. Why?
Because in the question ...
3
votes
Accepted
Dynamically add option to Jform field
You're already aware of Joomla\CMS\Form\Field\ListField::addOption() method. value is an attribute in the XML so it needs to be passed along with other attributes in the second argument:
$this->...
2
votes
Accepted
Adding Custom Fields to Article Component [Not in attribs field]
I would recommend using FieldsAttatch for this, see http://www.fieldsattach.com/ for more info.
It is not a full on CCK, but a much lighter system that allows you to add fields to the Joomla content ...
2
votes
Accepted
Loading the options of a select form field via jQuery Ajax
If I rightly remember, you need to update it if any dynamic changes are made.
You can do so with the following:
jQuery('#jform_student_ids').trigger("liszt:updated");
Hope this helps
2
votes
Using JHtml::_('behavior.formvalidator') in JForm gives empty error messages
The problem is you haven't set the Error messages, so no error message is shown. You need to include:
message="This field is required!"
You were using description="" and this is shown in the ...
2
votes
How do I remove and/or change the 'name' field in the registration form so that I can ask for first and last name separately?
You can create another Registration controller and override the register() behavior.
<?php
class UsersControllerRegistration2 extends UsersController
{
public function register()
{
...
2
votes
How do I remove and/or change the 'name' field in the registration form so that I can ask for first and last name separately?
Let me start by saying I do not condone this method, the next time you update Joomla there is a high probability you will undo these changes completely.
This is however a working method to do what ...
2
votes
Accepted
How to set the form validation only for the fields that are shown
I managed to achieve this via setFieldAttribute. In the XML form I removed the field2 required property and set that dynamically in the form as below.
echo $this->form->renderField('field1');
...
2
votes
Accepted
How to add attribute to <form> of backend for module
The short answer is there's an "easier" way. The assumption being you need to provide a means for a user to upload a file as part of the core configuration of the module. Since there isn't a ...
2
votes
Show Form Field if AJAX-response is false
Well you could attach your hide/show functions within the success parameter of the ajax method.
var showMethod = function () {
// show method code...
}
var hideMethod = function () {
// hide ...
2
votes
Accepted
How to use a custom layout with JForm subform fields?
To place a subform (Joomla! 3.6+) within another "master" form and use a custom layout:
1) In the master JForm XML file use the subform field type.
<field name= "fieldname"
description= "...
2
votes
Accepted
How to select predefined options in an custom form list-field?
I had to do the same thing. I copied the list form field code and changed it accordingly, so I have 2 functions:
getInput()
getOptions() which you have
In the getInput function, that's what actually ...
2
votes
Custom fields "on demand"
If you have used jform then You can use Subform field.
Read here more about Subform repeatable field
2
votes
Accepted
Why does Joomla remove html tags from submitted text even when filter types are set to raw?
Using $_POST as array key in getArray() argument is producing a warning:
Warning: Illegal offset type
If your form is using form control (normally jform), you can get unfiltered data like this:
$...
2
votes
Accepted
How to submit JForm form based on custom dropdown list value change
onchange attribute can be added to the fields in your XML form. E.g. this is used in filter forms:
<field
name="access"
type="accesslevel"
label="JOPTION_FILTER_ACCESS"
description=...
2
votes
Dynamically removing single JForm option
The small problem with your question is that <option> is not a field attribute but an element in XML, so you cannot set or remove that using methods for field attributes.
You can remove however ...
2
votes
Dynamically removing single JForm option
So this is what I've done:
protected function preprocessForm(JForm $form, $data, $group = '')
{
$app = JFactory::getApplication();
...
if ($app->isClient('site')) {
// ...
2
votes
Dynamically removing single JForm option
Another option could be to place the two versions of the field in separate .xml files in your /forms folder and then decide which one to load.
If ($option == 1)
{
$form->loadFile('...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
jform × 126joomla-3.x × 53
form-fields-types × 15
component × 13
custom-field × 13
form × 13
model × 12
joomla-3.4 × 11
fields × 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