Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Looking to override package files/classes
  • I am looking to add some customizations to the Orm package for its observer/validation.php class.

    I tried the add_classes override in my config.php like when overriding core classes but it appears to be ignored or already loaded by time it gets there.  For time being I have just edited the Orm bootstrap.php to point to my custom validation class.

    Is there an out of box and clean way to do this?  Or just via creating and clone of the Orm package as "MyOrm" or equivalent?
  • The Orm package doesn't contain core classes, so there's nothing to override.

    You can only extend the Orm classes in the traditional way, but they will not be used by the Orm model unless you change that too.

    What customizations are you thinking about that you need to change the observer for it?
  • Dont know the full extent of the customizations yet, just started jumping into first fuel project this week.  First thing I am doing is adding new field types and processing.., for example first one is a "calendar" field that when passing the model to fieldset and build() is called it will render a js date picker popup.

    Bigger effort to look at down the road after getting my initial project done, but would like to rewrite or see new way fields are handled in more pluggable manner.  Right now there are too many touch points to add a new type.

    I guess for now I will keep using my override files for where I need to tap in and change the behavior, as well as spend some spare cycles looking at how a new way of handling fields might be best implemented
  • Seems like a complicated way of doing things. i just add 'datepicker' to the class value of the form array, and use some jQuery magic to add the datepicker to all fields with this class defined.

    Ideally, from a "separation of concerns" point of view, you want like to avoid code that generates HTML.

  • I am using custom styled date/calendar fields that are leveraging some bootstrap css extensions.., so the markup isnt just standard field with custom class attribute.


  • HarroHarro
    Accepted Answer
    I only use it to trigger a jQuery function. You can do in that what you want.
  • Sorry if it's been a year but I'm catching up to FuelPHP practices. You could use the http://fuelphp.com/docs/classes/html.html#/function_array_to_attr to insert code in your html code, and there other helpful methods in the form class as well.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion