Jump to:

5093 Posts in 1516 Topics by 1113 members

Customising the CMS

SilverStripe Forums » Customising the CMS » New Admin Module

Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2 3
Go to End
Author Topic: 2371 Views
  • Martijn
    Avatar
    Community Member
    270 Posts

    Re: New Admin Module Link to this post

    I created a CustomTextField and these includes work:

    <?php

    class CustomTextField extends TextField {
       
       function __construct($name, $title = null, $value = "", $maxLength = null, $form = null){
          
          $this->include_js($name);
          parent::__construct($name, $title, $value, $maxLength, $form);
       }
       
       public static function include_js($name){
          Requirements::javascript('productadmin/testcode/test.js'); // <--- works
       }
       
       function Field() {
          $attributes = array(
             'type' => 'text',
             'class' => 'text' . ($this->extraClass() ? $this->extraClass() : ''),
             'id' => $this->id(),
             'name' => $this->Name(),
             'value' => $this->Value(),
             'tabindex' => $this->getTabIndex(),
             'maxlength' => ($this->maxLength) ? $this->maxLength : null,
             'size' => ($this->maxLength) ? min( $this->maxLength, 30 ) : null
          );
          
          if($this->disabled) $attributes['disabled'] = 'disabled';
          Requirements::javascript('productadmin/testcode/test.js');   // <--- works   
          return $this->createTag('input', $attributes);
       }
    }

    The customScript in Field() does not work, but neither in ModelAdmin:

    Requirements::customScript("var test = 'test';", 'UniqueID');

    2371 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.