ExtJS 5 Dynamically chage a Hyberlink - extjs

I'm having some issue of using ExtJS-5 to set some Hyberlink which also could be dynamically changed(according to a REST GET call).
Now I'm able to set a label as a Hyberlink using it's 'html' config which makes it clickable and jump to another page. Also according to the DOC file, if I assign the 'text' config to a 'Label' it will disable the 'html' property and only display the 'text'. So now I can change the 'text' of label Dynamically but they are not clickable.
Questions:
Should I use 'Label' for what I'm trying to do or use something else?
DOC shows 'Label' has no getText or getHTML method, then how to read its 'value'? like I want to pass it to the BackEnd. (getValue() doesn't work)

Label is perfectly fine for doing this
ExtJS doesn't provide any method of getting text value, cause we can read it directly

Related

How to check whether a checkbox is checked or not in Ext JS 3 when 'name' attribute is used

I have checkboxes created in Ext JS. When defined with 'id' attribute, I'm able to check whether its checked or not, but this is resulting in a different functionality failure.
I want to check whether the checkbox is checked or not when those checkboxes are created using 'name' attribute instead of 'id' attribute.
Please help me
You can use ref attribute instead of id - http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.Component-cfg-ref

TinyMCE: cake php plugin [ cannot submit form ]

I use https://github.com/CakeDC/TinyMCE to download plugin and did follow all the step to integrate on my cakePHP project. so right now, all the textarea was successfully changed to tinyMCE editor
But when click "SUBMIT" to submit my form, page cannot submit and post data. Without loading editor my form can submit and post data.
Is any jquery problem ? please advise me.
thank you.
Bootsrab.php
CakePlugin::load('TinyMCE');
Configure::write('TinyMCE.editorOptions', array('width' => '500px','height'=>'250px' ));
Controller:
public $helpers=array('Html','Form','TinyMCE.TinyMCE');
View:
$this->TinyMCE->editor(array('theme' => 'advanced', 'mode' => 'textareas'));
echo $this->Form->input('user_requirements',array('required'=>true) );
Layout : default
loding js file:
echo $this->Html->script(array('ddsmoothmenu','jquery-1.7.1.min','jquery-ui-1.8.17.custom.min'));
You've set the field to be required, so the problem you are experiencing is probably the browser based form validation.
The problem is that the validation applies before TinyMCE injects the contents into the textarea, and so the validation will always fail as the textarea is empty. This is a very long known "bug" btw:
http://www.tinymce.com/develop/bugtracker_view.php?id=4768
http://www.tinymce.com/develop/bugtracker_view.php?id=5671
In Firefox you might notice a validation bubble that appears "behind" the browser in the bottom left corner of the screen, and in Chrome for example it would throw the following error: "An invalid form control with name='...' is not focusable".
The quick and dirty fix would be to set required to false. In order to keep the required class on the generated container div you would have to set this manually using the div option:
'div' => array('class' => 'input text required')
It's also possible to disable browser validation completely by defining the novalidate attribute on the form:
$this->Form->create('ModelName', array('novalidate' => true));
or using the formnovalidate attribute on the submit button:
$this->Form->submit('Submit', array('formnovalidate' => true));
Theoretically it would also be possible to listen to the invalid event and display custom validation bubbles, but the problem here is that the browser behavior is not consistent, ie in Chrome it's not possible to validate invisible (using display or visibility) fields. Also the content would still be missing in the textarea field.
What seems to work is using opacity to hide the field, that way one could position the textarea under the editor, and the validation bubble would be displayed correctly. However that would also require to inject the editor contents in the textarea manually when pressing Enter and when clicking the submit button (or probably even simpler using proper editor change events). I'll see if I can come up with an example for this later on.
Update: I've implemented a fix/workaround in form of a TinyMCE 4.x plugin, as this was bugging me in some of my own applications too, see https://github.com/ndm2/tinymce-validatable

Cakephp forms - Is there a way to make a field read only (in the view)

I have a Cakephp 1.3 form that allows users to edit the profile data. But some of the information in the forms needs to be read only (sometimes).
Is my only option to echo and format the field contents in the read only case or is there a flag in the Cake form that allows for read only fields. Ideally the read only fields would be greyed out similar to other interfaces.
echo $this->Form->create('User', array('url' => array('controller' => 'User', 'action'=>'editUser')));
echo $this->Form->input('id', array('type'=>'hidden'));
If (!isset($IsAdmin)) {
// Only display username - read only! Add code here
echo $this->Form->input('username', array('label' => __d('users', 'User',true)));
} else {
// Admins can edit user names
echo $this->Form->input('username', array('label' => __d('users', 'User',true)));
}
... more fields here
echo $this->Form->end(__d('users', 'Submit',true));
You can add a 'disabled' key to the options array, however realise that this is only the front-end/presentation of the form, people will be able to override the 'disabled' property of the input field and modify its value.
To prevent unwanted changes to be saved, you need to specify a 'fieldList' when saving the data using your model
To output a disabled form field;
echo $this->Form->input('fieldname', array('type'=>'hidden', 'disabled' => 'disabled'));
Then, when saving the data, specify a fieldlist (documentation: http://book.cakephp.org/1.3/en/The-Manual/Developing-with-CakePHP/Models.html#saving-your-data)
$this->MyModel->save($this->data, true, array('field1', 'field2'));
The fieldlist should include all fields that are allowed to be updated by the user
The disabled attribute is fine but actually, input fields have a 'readonly' attribute. And it sounds like you want the field to still be shown to the user so using 'hidden' isn't really addressing what you want done.
So an alternative (and actually specifically addressing your requirement for 'read only'):
echo $this->Form->input('fieldname', array('readonly' => 'readonly'));
I found that using disabled prevents jquery click triggers from firing versus readonly still fires e.g. using a bootstrap datepicker text field
Here's a link to WC3 for it: http://www.w3schools.com/tags/att_input_readonly.asp
if you really want to make a field read only why you want to use form field, just echo the value, one can easily change disable or readonly attribute of form field with simple javascript or firebug.
Okay, after having tried several approaches, here is what I like.
1) Use readonly (disabled will remove the value after hitting "save", when you are in update mode, which sucks):
echo $this->Form->input('email', array('readonly' => 'readonly'));
2) To prevent this from updating when removing 'readonly' via browser plugins, you can add this to beforeSave of your model:
if(isset($this->data[$this->alias]['id'])) // id is only set if we update
{
unset($this->data[$this->alias]['email']);
}
Field lists are not comfortable. Why should I add all the fields, when I actually only want to exclude one?
Unsetting will prevent CakePHP from updating it in the database. Of course, after hitting save with an (invalidly) updated e-mail address, this update will be shown in the form once. But as the user has manipulated the HTML form and since the database field stays unchanged, this should not matter.
You can do either of two things:
Make the field hidden
(Ex. echo $this->Form->input ('username, array ('type' => 'hidden'));
Reset the value of username to it's original value, before submitting the form or possibly in beforeSave.

How to generate 'a href="javascript:void(0)"' like link in cakephp?

How to generate 'a href="javascript:void(0)"' like link in CakePHP?
I make an application, the content will insert into the editor textarea when user click a list of image. I add a class to these images and write some code in the javascript file. Everything is going well.
But the link of the image is a URL address, but not 'href="javascript:void(0)' like URL. Anyone could tell me how to make it in CakePHP?
Thanks in advance!
<?php
echo $this->Html->link(
'/path/to/image/',
'javascript:void(0)'
);
?>
You can either set a path to the image or use the Html helper to generate the image tag code. The second parameter will set the href.
Don't believe there is any dynamic way, however when you are creating your form element you can set it in the options array 'href' => 'javascript:void(0)'

Drupal 7: Modifying menu HTML output?

I am trying to modify the HTML output in a Drupal 7 theme that I am creating.
Basically, instead of the < li >s containing just plain < a >s with text, I want to include some additional HTML inside the < a >.
I know that it's possible to modify the HTML created by the menus in Drupal. I can see the following call in page.tpl.php:
<?php print theme('links__system_main_menu', array(
'links' => $main_menu,
'attributes' => array(
'id' => 'main-menu',
'class' => array('links', 'clearfix'),
),
'heading' => array(
'text' => t(''),
'level' => 'h2',
'class' => array('element-invisible'),
),
)); ?>
which apparently calls the theme function, which creates the output. One way to modify the output would be to modify the theme_links function in theme.inc, right?
http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_links
I also know that you can put a hook in template.php to override the function which creates the HTML. I can't figure out how to create the actual override function. Can somebody point me in the right direction, please?
What you would do is implement a hook to modify the output, not modify the "theme.inc" file directly.
For example, the accepted answer on this page: Drupal Override Custom Menu Template
And as a general rule, when you want to modify the output of something, either implement a hook (in a module or in the template.php of the active theme) or use a template with a predefined file name when such a case exists (when no template already exists, you can also modify the list of template suggestions using a module or the theme).

Resources