Help with page variables

edited October 2012 in News & Announcements
Hello,

I have implemented the tank_auth system in my site.

The auth contorller is rendering a register form.

I need to add a jquery file to the register form (http://localhost/mysite/auth/register), I tried a few ways but none of them work:

1. I add this line in the global variables file: $pages['register'] = array('js'=>'masked.js');
2. I add this line in the global variables file: $pages['auth/register'] = array('js'=>'masked.js');
3. I have copied the global variables file, saved it as register.php in the views/_variables folder and added the jquery file to the js array.

How can I add the jquery file to the register form?

Comments

  • edited 5:25AM
    Does your header (or footer) have something like the following in it to merge in javascript:
    <?=js($js)?>
  • edited 5:25AM
    Yep, my header view in the _blocks folder has this: <?php echo js('jquery, main'); ?> <?php echo js($js); ?>

    And I see the jquery files that are set in the global variables files like so:
    $vars['js'] = array('jquery-ui-1.9.0.custom.min', 'calllogin'
  • edited 5:25AM
    How it he controller rendering the page? Is it using $this->fuel_page->render()? That method allows for the variables to be included into pages.
  • edited 5:25AM
    There is the function from the controller:
    function register() { if ($this->tank_auth->is_logged_in())// logged in { redirect(''); } elseif (!$this->config->item('allow_registration', 'tank_auth'))// registration is off { $this->_show_message($this->lang->line('auth_message_registration_disabled')); } else { if (!empty($_POST) /*AND $_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR']*/) { // put your processing code here... we show what we do for emailing. You will need to add a correct email address if ($this->_processRegister($_POST)) { $this->session->set_flashdata('success', TRUE); redirect('auth/register'); } } $this->load->library('form_builder'); $fields = array(); $captcha_registration = $this->config->item('captcha_registration', 'tank_auth'); $use_recaptcha = $this->config->item('use_recaptcha', 'tank_auth'); $fields['firstname'] = array('label'=>'First Name', 'size' => 60, 'required' => TRUE); $fields['lastname'] = array('label'=>'Last Name', 'size' => 60, 'required' => TRUE); $fields['phone'] = array('size' => 15, 'required' => TRUE, 'class'=>'phone'); $fields['secondaryphone'] = array('label'=>'Secondary phone', 'size' => 15, 'class'=>'phone'); $fields['email'] = array('size' => 30, 'required' => TRUE); $fields['jobtitle'] = array('label'=>'Job Title', 'type' => 'select', 'options' => array('select' => 'Select your job title', 'Supplier' => 'Supplier', 'Transporter' => 'Transporter', 'Trader' => 'Trader', 'Broker' => 'Broker'), 'required' => TRUE); $fields['spam'] = array('type'=>'hidden'); if ($captcha_registration) { if ($use_recaptcha) { $fields['recaptcha_html'] = $this->_create_recaptcha(); } else { $vars['captcha'] = $this->_render_captcha(); if (!empty($vars['captcha'])) { $fields['captcha'] = array('required' => TRUE, 'label' => 'Security Text', 'value' => '', 'after_html' => '<br><span class="captcha">'.$vars['captcha']['image'].'</span><br /><span class="captcha_text">'.lang('captcha_text').'</span>'); } } } $this->form_builder->set_fields($fields); $this->form_builder->set_validator($this->validator); $this->form_builder->set_field_values($_POST); $this->form_builder->display_errors = TRUE; $this->form_builder->required_text = '<span class="required">*</span>Required fields'; $vars['form'] = $this->form_builder->render(); $page_init = array('location' => 'auth/register_form'); $this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init); $this->fuel_page->add_variables($vars); $this->fuel_page->render(); } }
  • edited 5:25AM
    I'm not quite sure why that may not be getting passed to you. However, you can try adding the following to the controller to get passed in the add_variables method:
    $vars['js'] = 'masked.js';
Sign In or Register to comment.