robclancy / presenter

Decorate your objects using presenters. Primarily to keep presentation logic out of your models.
MIT License
345 stars 38 forks source link

Presenter breaking Laravel Form::model functionality #16

Closed christoferd closed 11 years ago

christoferd commented 11 years ago

Hi Rob,

I believe Presenter is breaking Laravel Form::model functionality.

Controller:

$codesJob = $this->codesJob; // Model Object
// Inject default Title
$codesJob->title = 'My Codes Job Title';
// Pass Model with injected data
return View::make('system/codes_job/create', compact('codesJob'));

Model:

use Robbo\Presenter\PresentableInterface;
class CodesJob extends Eloquent implements PresentableInterface {
... 
}

View:

{{ Form::model($codesJob, array('route' => array('job.create'))) }}
{{ Form::text('title', null, array('class' => 'form-control')) }}

This only works when removing Presenter stuff from the Model. ie. only have class CodesJob extends Eloquent

Any ideas on how I can keep Presenter and still have all of Laravel core functionality working?

Thank you :)

robclancy commented 11 years ago

I don't and never will support the Form class as I am completely opposed to it ever being used.

However $presenter->getObject() was added so you can get the actual object from within views. So in your examples you would just do $codesJob->getObject() and it should work.

christoferd commented 11 years ago

@robclancy Do you auto generate forms instead? If not using Form class what do you use?

Just trying to learn, thanks :)

robclancy commented 11 years ago

I write HTML. I am against replacing one syntax with another just for the sake of it. And then even more against a view depending on a model.

Although I use angular now so barely touch blade at all.

christoferd commented 11 years ago

I agree. Thanks for info.

PS: Mainly use this to learn and practice. However a cool feature, in L4, Form::model now handles auto injecting values into form fields if they exist in Session, Post, or Model object properties. Keeps my form code cleaner not having to check and inject values after submit errors.

On 5 September 2013 08:57, Robert Clancy (Robbo) notifications@github.comwrote:

I write HTML. I am against replacing one syntax with another just for the sake of it. And then even more against a view depending on a model.

Although I use angular now so barely touch blade at all.

— Reply to this email directly or view it on GitHubhttps://github.com/robclancy/presenter/issues/16#issuecomment-23832359 .