Sending data for conditional check across Chronoform V5 multipage form for Joomla CMS - joomla3.0

I am using Chronoform V5 for my Joomla site. I have created a Multi Page form wherein a user will fill in each page and click next to proceed and at the end the form will be finally submitted and some results will be displayed based on the input. This part works fine.
Now I have a dropdown in first page. If a user selects e.g, option 'a' and clicks 'next page' button i want to hide a dropdown in the second page. In case the user selects option 'b' in the first page this dropdown in second page should be visible.
Any idea how to achieve this?

I would use a Custom code action to check the submitted value and use CSS to show or hide the value:
<?php
$display = 'block';
if ( $form->data['var_name'] == 'xxx' ) {
$display = 'none';
}
$style = "#some_id { display: '{$display}'; }";
$jdoc = \JFactory::getDocument();
$jdoc->addStyleDeclaration($style);
?>

Related

Show PopupMenu in Ag-Grid

How can I show programmatically the column PopupMenu in Ag-Grid?
PopupMenu Ag-Grid
With the gridApi you can hide it, but not show it
gridApi.hidePopupMenu()
I try also with the FilterInstance and the columnApi, but I haven't found anything that works
gridApi.getFilterInstance(colKey)
gridColumnApi?.getColumn(colKey) ...
Thanks
you can add a little workaround to open the filter popup:
// find the header menu button for the desired column
const colElement = document.querySelector("div[col-id='" + desiredColumn.getColId() + "'] > .ag-cell-label-container > .ag-header-cell-menu-button");
colElement.dispatchEvent(new Event("click")); // simulate a click on the menu button
// the next part ist to switch to the filter tab:
setTimeout(() => { // give the browser some time to render the menu
const tabElement = document.querySelectorAll("div.ag-tabs-header > .ag-tab")[1]; // select the filter tab
if (!tabElement.classList.contains("ag-tab-selected")) { // if the filter tab is not selected already
tabElement.dispatchEvent(new Event("click")); // click the filter tab
}
}, 10);
Basically, you locate the button in the DOM and execute a virtual click on it. It's not pretty but it works well, maybe we'll get an API for this in the future.
What you're wanting to do is to access getFilterInstance() of the Ag Grid API. Here's the relevant documentation: https://www.ag-grid.com/javascript-grid/filter-api/
Here's one way of accessing, and setting the filter using the getFilterInstance method
var FilterComponent = gridOptions.api.getFilterInstance('Status');
FilterComponent.selectNothing(); //Cleared all options
FilterComponent.selectValue('Approved') //added the option i wanted
FilterComponent.onFilterChanged();
Here's a related Stackoverflow question: how to pre-set column filter in ag-grid

Drupal 7, how to add text to the user profile page

I need to add a paragraph of text near the top of the user profile page found at /user, this is page you are initially taken to after login.
I'm not fluent with Drupal, and I can't find any answers online.
Could any advise how I can add text to the user profile page?
you can also add a block to the "content area" to be shown below the user profile (restricted to user/* pages). In the block you an use short PHP snippets.
In a custom Drupal module you could use hook_form_FORM_ID_alter(), this will let you change the user profile form, where you could attach a div element that will hold the paragraph text you wish to insert to the page. You will also give weight to your div, so that it is displayed on top of the form.
Here is a code snippet:
function custommodulename_form_user_profile_form_alter() {
$description_html = '<div>Lorem ipsum...</div>';
$form['description'] = array(
'#markup' => $description_html,
'#weight' => -10,
);
}

Drupal Webform - How to load values from form, filled in a previous page

Working on Drupal, I have a page with a form made with "Webform" module, containing several fields (text fields and sliders) and a "Submit" button.
When the user enters the information and presses the "Submit" button, another page is loaded with custom code into it.
The new page is devided into 2 parts - the first one contains new information(based on the user input from the previous page); the second one contains (block) the same form, used in the previous page.
Is there a way to load the values, filled in the form from the first page into the new page?
First of all you would need to make a custom module, with the help of
hook_form_alter
You would need to store the previous form's information in cookies with prefix
Drupal_visitor_
and then display it in the new page like:
$form['submitted']['FirstName']['#default_value'] =
$_COOKIE[$firstname];
Thanks

'attributes' for login button in login form

I need to theme the login form. I need additional css classes and tabindex for the form elements.
Now I have a problem with these both for the login button.
In template.php I use 'attributes' for that. For e.g. the password field it works perfect with this code:
$form['pass']['#attributes']['class'][] = 'input-sm form-control';
$form['pass']['#attributes']['tabindex'][] = '2';
When I use this for the button - nothing is rendered in html:
$form['op']['#attributes']['class'][] = 'test-button';
$form['op']['#attributes']['tabindex'][] = '3';
'op' is the name of the login button which I can see in html output.
How can I get the 'class' and 'tabindex' to the login button?
For the button you should use $form['#submit'].
In any case you can use hook_form_alter() and devel's dpm($form) to get the form data. A generic example:
function MYTHEME_form_alter(&$form, &$form_state, $form_id) {
dpm($form);
}
The submit button may be accessed like this for a common Drupal theme (structure taken from the dpm() function):
$form['actions']['submit']['#attributes']['tabindex'][] = "2";
One important thing here is to be careful because you may override the form again later on your theme... In this case look for the very last hook and apply changes there.

Cakephp 2.0 Pagination with dropdown

I am doing pagination in cakephp. By default there is a list in
"$this->Paginator->numbers" but i want some changes in pagination design so i want all pages in dropdwon and current page is selected in dropdown. I successfully get the dropdown by writing the following code but the problem is that when i click on the page it wil not change
thanks in advance
`
< select>
echo $this->Paginator->numbers(array('tag'=>'option'));
</select>
`
You have to bind event onChange to your select element with JS. It should redirect you to selected page. You can see how to construct jump url in cake's documentation. You can also use this solution but notice it was written for cake 1.x and will need some changes.

Resources