Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Model Admin display bug?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 1850 Views
  • webtonic
    Avatar
    Community Member
    26 Posts

    Model Admin display bug? Link to this post

    Hi Guys

    I have tried to extend ModelAdmin and all seems ok until I click in the search option and the ctf looks like it is not loading its style sheet (image attached). I am running 2.4 and has tried this on 3 different servers and had the same result. Al with fresh installs.

    if you have any ideas I would appreciate it. The weird thing is on the wamp server on my pc it is perfect!

    thanks Craig

  • cuSSter
    Avatar
    Community Member
    56 Posts

    Re: Model Admin display bug? Link to this post

    Is this on the live site?

  • webtonic
    Avatar
    Community Member
    26 Posts

    Re: Model Admin display bug? Link to this post

    Yes this is on the live site

  • cuSSter
    Avatar
    Community Member
    56 Posts

    Re: Model Admin display bug? Link to this post

    Can you post the class that you have created?

  • webtonic
    Avatar
    Community Member
    26 Posts

    Re: Model Admin display bug? Link to this post

    3 files

    VehicleAdmim.php

    <?php
       class VehicleAdmin extends ModelAdmin{
          static $managed_models = array ('Vehicle');
          
          static $url_segment = "trucks";   
          static $menu_title = "Trucks";
          
          
       }
    ?>
    Vechicle.php

    <?php
    class Vehicle extends DataObject
    {
       static $db = array(
       "Stockcode"=>"Varchar(64)",
       "Category"=>"Enum('Truck,Trailer','Truck')",
       "Type"=>"Varchar(64)",
       "Make"=>"Varchar(64)",
       "Model"=>"Varchar(64)",
       "Year"=>"Int",
       "Colour"=>"Varchar(32)",
       "Vin"=>"Varchar(64)",
       "Engine"=>"Varchar(64)",
       "Horsepower"=>"Int",
       "Transmission"=>"Varchar(64)",
       "Wheelbase"=>"Varchar(64)",
       "Speedo"=>"Varchar(32)",
       "Tare"=>"Varchar(32)",
       "Gvwrating"=>"Varchar(64)",
       "Gcwrating"=>"Varchar(64)",
       "Regnum"=>"Varchar(64)",
       "Regexpiry"=>"Varchar(64)",
       "Additional"=>"Varchar(255)",
       "Price"=>"Currency",   
       "Cofexpiry"=>"Varchar(64)",
       "Axelconfig"=>"Varchar(64)",
       "Rearaxels"=>"Varchar(64)",
       "Suspension"=>"Varchar(64)",
       "Towingeye"=>"Varchar(64)",
       "Hubometer"=>"Varchar(64)",
       "Roaduserkms"=>"Varchar(64)",
       "Deck"=>"Varchar(64)",
       "Drawbeamcert"=>"Varchar(64)",
       "Chassismod"=>"Varchar(64)",
       "Anchorage"=>"Varchar(64)",
       "Nzhbc"=>"Varchar(64)",
       "Kingpincert"=>"Varchar(64)",
       "Fifthwheel"=>"Varchar(64)",
       "Twistlocks"=>"Varchar(32)",
       "Tyreinfo"=>"Varchar(64)",
       "Tyrefront1"=>"Varchar(32)",
       "Tyrefront2"=>"Varchar(32)",
       "Tyrefront3"=>"Varchar(32)",
       "Tyrefront4"=>"Varchar(32)",
       "Tyrerear1"=>"Varchar(32)",
       "Tyrerear2"=>"Varchar(32)",
       "Tyrerear3"=>"Varchar(32)",
       "Tyrerear4"=>"Varchar(32)",
       "Condition"=>"Enum('New,Used','New')",
       "Description"=>"Varchar(127)",   
       );
       
       static $field_labels = array(
       "StockCode"=>"Stock Code",
       "Vin"=>"Vin Number",
       "Engine"=>"Engine Type",
       "Horsepower"=>"Engine Horsepower",   
       "Speedo"=>"Speedo Reading",
       "Tare"=>"Tare Weight",
       "Gvwrating"=>"GVW Rating",
       "Gcwrating"=>"GCW Rating",
       "Regnum"=>"Registration Number",
       "Regexpiry"=>"Registration Expiry",
       "Additional"=>"Addition Information",   
       "Cofexpiry"=>"COF Expiry",
       "Axelconfig"=>"Axel Configuration",
       "Rearaxels"=>"Rear Axels",
       "Suspension"=>"Rear Suspension",
       "Towingeye"=>"Towing Eye Size",
       "Roaduserkms"=>"Road User Kms",
       "Deck"=>"Deck Type & Length",
       "Drawbeamcert"=>"Drawbeam Cert Expiry",
       "Chassismod"=>"Chassis Mod Expiry",
       "Anchorage"=>"Load Anchorge Expiry",
       "Nzhbc"=>"NZHBC Compliance",
       "Kingpincert"=>"Kingpin Cert Expiry",
       "Fifthwheel"=>"5th Wheel Mount Cert",
       "Twistlocks"=>"Twist Locks Fitted/Cert",
       "Tyreinfo"=>"Tyre Information",
       "Tyrefront1"=>"Front 1",
       "Tyrefront2"=>"Front 2",
       "Tyrefront3"=>"Front 3",
       "Tyrefront4"=>"Front 4",
       "Tyrerear1"=>"Rear 1",
       "Tyrerear2"=>"Rear 2",
       "Tyrerear3"=>"Rear 3",
       "Tyrerear4"=>"Rear 4"
       );
       
    static $has_one = array();

    static $has_many = array (
          'Photos' => 'Photo'
       );
    public function getCMSFields()
       {

          $f = parent::getCMSFields();
          $manager = new ImageDataObjectManager(
             $this, // Controller
             'Photos', // Source name
             'Photo', // Source class
             'PhotoPic', // File name on DataObject
             array(
                'PhotoHeading' => 'Photo Heading',
                'PhotoText' => 'Photo Copy'
             ), // Headings
             'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
                
    // Filter clause '`GalleryPageID` = '.$this->ID.''
             // Sort clause
             // Join clause
          );
          
           $manager->setAddTitle("Image");
    //$f->addFieldToTab("Root.Content",$manager);
          return $f;
       }

    static $searchable_fields = array("Stockcode","Make","Model","Type");
    static $summary_fields = array("Stockcode","Make","Model","Type");
    }
    Photo,php

    <?php

    class Photo extends DataObject{
    static $db = array(
    'PhotoHeading' =>'Text',
    'PhotoText' =>'Text'
    );
    static $has_one = array(
    'PhotoPic' => 'Image',
    'Vehicle' => 'Vehicle'
    );

       
    }
    ?>

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Model Admin display bug? Link to this post

    Hi,

    A couple of notes...

    1) an empty has_one is not required (only specify what you need)
    2) in the case of summary_fields being the same as searchable_fields - you only need summary_fields
    3) I'd remove almost all the code, dev/build, view, add items back in one by one to fix this

    I cannot see the error right off, but I have had strange results from ModelAdmin and it can be a pain to find out what it was, but starting with a clean install and the smallest code and working up gets it working in the end?

  • cuSSter
    Avatar
    Community Member
    56 Posts

    Re: Model Admin display bug? Link to this post

    Hi,

    Try adding the following lines of codes to your VehicleAdmin.

    public static $url_rule = '$Action/$ID';

    public static $model_importers = null;

    public function getModelImporters() {
          return null;
    }

    Then hit me back with the result.

  • webtonic
    Avatar
    Community Member
    26 Posts

    Re: Model Admin display bug? Link to this post

    Hi Pinoy

    No change at all in the results.

    thanks
    Craig

    1850 Views
Page: 1 2
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.