CJuiautocomplete with multiform model - php

I am using a multi form model. A $model array is passed to the view and for each model object I am trying to have a text field and it works fine this way. See the code below.
foreach ($model as $f=>$edu):
echo $form->textField($edu,"[$f]schoolname",array('size'=>30,'maxlength'=>128));
I am trying to have an autocomplete text field coded replacing the activeform text field. It is not working. Any ideas how to make this work.See the code below.
foreach ($model as $f=>$edu):
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'model'=>$edu,
'attribute'=>"[$f]schoolname",
'source'=>$this->createUrl('AutoComplete/acschoolname'),
// additional javascript options for the autocomplete plugin
'options'=>array('showAnim'=>'fold',),
'htmlOptions'=>array('size'=>'30','maxlength'=>'128',)
));

This appears to be a bug in Yii. Tabular form input is broken with widgets.
A workaround was posted in the Yii forums. I haven't tested it, but it's reported to work:
http://www.yiiframework.com/forum/index.php?/topic/10685-collecting-tabular-input-with-zii-jui-widgets-is-broken/
Baiscally, around Line 82 in CJuiAutoComplete.php, comment out the following lines:
//else
//$this->htmlOptions['name']=$name;
To make sure you are not modifying the Yii core and breaking upgrades, I would copy CJuiAutoComplete.php in to your /components folder and rename it MyJuiAutoComplete or something, and call that instead of CJuiAutoComplete.
Good luck!

Related

How to change Sign up page design in Moodle

I am new to moodle and i am using 2.9. I have a separate design for Signup page (HTML5 & CSS). How to integrate this page ?
I know the process of changing the default Login page like this
In config.php of my theme
'login' => array(
'file' => 'login.php',
'regions' => array(),
'options' => array('langmenu'=>true),
),
Where my Custom login page is login.php which is placed in my layout folder. So in this way i can takeover Login page design with my new design.
But i don't see any signup array in config page for Registration. So anyone can tell me how to do this change ?
Edit - I have checked this file moodle2\login\index_form.html I can see the signup design. But my issue is that file index_form.html has Moodle core CSS if i add my CSS there it will conflict also i dont know how to load the CSS from my theme folder to index_form.html.
Can anyone guide me ?
I already checked Moodle.org forum but not able to find the process.
Thanks In Advance
Lorry
Further to what #davosmith mentioned, you can actually use the existing auth/email plugin as a base for your plugin, So:
Copy auth/email and rename it to whatever you want, for example auth/foo. And rename all other instances of "email" to "foo".
Copy the login/signup_form.php to your plugin directory
in your auth/foo/auth.php file, add a function:
function signup_form() {
global $CFG;
require_once($CFG->dirroot.'/auth/foo/signup_form.php');
return new login_signup_form(null, null, 'post', '',
array('autocomplete'=>'on'));
}
Modify the auth/foo/signup_form.php to whatever you want
Hiii,
I'm one of the Moodler who working with Moodle.
to edit the signup page go at the following location and open the signup.php file.
./moodle/login/signup.php
in that file you can see at bottom of the page three lines.
...
echo $OUTPUT->header();
$mform_signup->display();
echo $OUTPUT->footer();
in which $mform signup->display(); create a form yu can comment and write HTML for your sign up form.
But make sure about the Action URL and the validations.
$mform is the object that create form and its class file is signup_form.php.
Hope it helpful for you ... Good Luck ['}
If you are wanting to avoid making changes to the core code in Moodle (which should almost always be what you want), then you can create a new signup form from scratch by first creating a new authentication plugin (in auth/NAMEOFPLUGIN).
When you create the authentication plugin, you should make sure that the 'can_signup' function returns true, that the 'user_signup' function does whatever processing is needed to create the new user account and that the 'signup_form' function returns a custom Moodle form that contains the fields you want.
It is possible to further customise this form by outputting custom HTML elements (using $mform->addElement('html', 'The HTML to output'); ). I would not advise completely abandoning the Moodle form (i.e. to replace it with hand-coded custom elements), as that will not be compatible with the signup code in login/signup.php (as well as losing the validation rules that are supported by the forms library).

how to use wp editor

i am newbie to wordpress theme development...
i know to create theme options in wordpress themes but now i want to use WYSIWYG Editor of wordpress, the wp_editor(), i have read some tuts on this but i can't make it...
here is my code:
add_settings_field('tinytxt', 'WYSIWYG: ', array($this, 'tinytxt'), 'oditer_theme_options', 'jd_theme_options_main_section');
public function tinytxt() {
wp_editor("{$this->options['tinytxt']}", 'tinytxtboom');
}
And how to retrieve the saved content from the database, i know to use get_option()...
thanks in advance...
You need to give your WordPress editor a name for the input, so that it can save the value.
wp_editor( $this->options['tinytxt'], 'tinytxtboom', array(
'textarea_name' => 'jd_theme_options[tinytxt]'
) );
This will give the hidden textarea wp_editor uses a name for the form submission. jd_theme_options matches the second argument to register_setting, and tinytxt is the option key you want to save the value under.
I think that's all you need. Comment if you have trouble. I'll be back tomorrow to check.
You could also try getting it to work with just a simple textarea, then try to get the wp_editor working.

How to load a magento view (.phtml) file from a controller

Im trying to load a rendered version of the cart sidebar, which i intend to load via ajax... I've been searching around alot and it seems like the best approach is to create a custom module which will handle all my ajax request. I have created a custom module and everything seems to be working however when I display the sidebar.phtml it is not rendered properly. It displays as if there is nothing in the cart. (im assuming its just trying to reading the file without using any session info). I've search a bunch but nothing seems relevant to what I'm trying to do.
This is the code im using in my custom controller to load the phtml file which is essentially a copy and past of the checkout/cart/sidebar.phtml file.
$layout = $this->loadLayout();
$block = $this->getLayout()->createBlock(
'Mage_Core_Block_Template',
'PPWD_Custom',
array('template' => 'custom/custom.phtml')
);
echo $block->toHtml();
Thanks
The problem is in incorrect block type. Instead of Mage_Core_Block_Template you should use Mage_Checkout_Block_Cart_Sidebar. Like this:
$this->getLayout()->createBlock(
'checkout/cart_sidebar',
'PPWD_Custom',
array('template' => 'custom/custom.phtml')
);

Drupal Form-API: #field_prefix doesn't work on textfield

I'm trying to implement #field_prefix on a text field so I can add some extra UI to my form.
I have a module where I'm doing other overrides like this, with a function that basically looks like this:
function modulename_form_alter(&$form, $form_state, $form_id){
if ($form_id == "contenttype_node_form"){
$form['field_contenttype_fieldname'][0]['#prefix'] = 'prefix'; //this line works
$form['field_contenttype_fieldname'][0]['#field_prefix'] = 'field_prefix'; //this line doesn't work
}
Here's the docs, seems pretty straight forward:
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html/6#field_prefix
I've renamed my theme to effectively disable it - should prove I don't have any other overrides hanging around that would conflict.
What am I missing?
Update:
Ended up overriding theme_form_element to insert my prefix manually when the #field_name meets the right condition. Feels hacky, but text_textfield simply doesn't support #field_prefix.
My guess is that as a CCK field field_contenttype_fieldname isn't actually a textfield, but a custom FormAPI field CCK provides that's like a textfield, and as such it doesn't consume the field_prefix attribute.
Try print_r()ing that field out of the $form and see what its #type is.

Changing CCK Title for Form

By default a CCK form creation has a title of the form
Create [Your Content Type Name Here]
I want to change mine to
Register for Such and Such
It was suggested that I could use string-override, but I can't find the string to replace. I've also tried writing code to form_alter, but can't seem to figure out how to get the "title" to change.
Ideas?
There are two possibilities, either you can use the theming laying and set $title variable used in the page templage. You can do this with a preprocess function like lazy suggests.
The other options which I prefer would be to use the drupal_set_title(), this would need to go in a module. I haven't tried this, but I would think that you could use this in your hook_form_alter() implementation. That way you could control which titles get changed pretty easily.
Hook form_alter doesn't affect the title, but you can use a preprocess function:
Try this code to start:
function MYMODULENAME_preprocess(&$variables) {
$variables['title'] = 'test title';
}

Categories