two questions modeladmin 3.1

14 views
Skip to first unread message

Nicolaas Thiemen Francken - Sunny Side Up

unread,
Oct 15, 2013, 2:51:38 AM10/15/13
to Silverstripe Ecommerce
Hi Folks

I am wondering if someone can help me with two problems (looking at best practice).

1. I want to be able to make BillingAddresses (and other classes) to be able to be created (canCreate = true) only when they are created in the context of an Order (so you create an order and then you add the billing address to it). You can change the canCreate function, but that feels a bit clumsy....  Any ideas / recommendations?

2. what if the title of an object is HTML rather than Varchar, then how do you change the title of the modeladmin - example shown below:

Inline images 1

Any ideas?  Maybe have an alternative title I guess. That would require a lot of changes... 

--
Nicolaas 
image.png

Steven Mohr

unread,
Oct 15, 2013, 7:00:22 PM10/15/13
to silverstrip...@googlegroups.com, n...@sunnysideup.co.nz, ma...@sunnysideup.co.nz
2.
public function getTitle() {
 
if( is_subclass_of(Controller::curr(), "LeftAndMain")  )
   
return "my non html title";
 
return $this->getField('Title');
}



Steven Mohr

unread,
Oct 15, 2013, 7:25:01 PM10/15/13
to silverstrip...@googlegroups.com, n...@sunnysideup.co.nz, ma...@sunnysideup.co.nz
I just realized after posting that that it will also affect your Title field, not just the title in the Breadcrumbs.
You may need to manually insert the title into your field in getCMSFields so it doesn't use the getTitle() function.

Nicolaas Thiemen Francken - Sunny Side Up

unread,
Oct 15, 2013, 7:30:47 PM10/15/13
to Silverstripe Ecommerce
BRILLIANT.... THANK YOU!


On 16 October 2013 12:25, Steven Mohr <st...@klundthosmer.com> wrote:
I just realized after posting that that it will also affect your Title field, not just the title in the Breadcrumbs.
You may need to manually insert the title into your field in getCMSFields so it doesn't use the getTitle() function.

--
You received this message because you are subscribed to the Google Groups "Silverstripe Ecommerce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-ecom...@googlegroups.com.
To post to this group, send email to silverstrip...@googlegroups.com.
Visit this group at http://groups.google.com/group/silverstripe-ecommerce.
For more options, visit https://groups.google.com/groups/opt_out.



--
Nicolaas Thiemen Francken  
Sunny Side Up Ltd  {
  Skype: atyourservicehour
  Phone: +64 4 889 2773 
  Emergencies: 0221697577
  n...@sunnysideup.co.nz
  http://www.sunnysideup.co.nz
}







Reply all
Reply to author
Forward
0 new messages