Skip to content

Instantly share code, notes, and snippets.

View frankmullenger's full-sized avatar

Frank Mullenger frankmullenger

View GitHub Profile
@frankmullenger
frankmullenger / SomeForm.php
Created October 31, 2011 01:29
Form validation messages
<?php
class SomeForm extends Form {
function validate(){
if($this->validator){
$errors = $this->validator->validate();
if($errors){
if(Director::is_ajax() && $this->validator->getJavascriptValidationHandler() == 'prototype') {
FormResponse::status_message(_t('Form.VALIDATIONFAILED', 'Validation failed'), 'bad');
@frankmullenger
frankmullenger / _config.php
Created March 6, 2012 04:54
Example _config.php settings for SwipeStripe
<?php
/**
* SwipeStripe settings
* ====================================================
*/
//License key
ShopSettings::set_license_key('');
@frankmullenger
frankmullenger / OrderPage.php
Created May 17, 2012 06:12
Payment Module Outlines
<?php
class OrderPage extends Page {
}
/**
* Represents a page with a form which a user fills out to process payment
*/
class OrderPage_Controller extends Page_Controller {
@frankmullenger
frankmullenger / _config.php
Created May 28, 2012 03:55
Payment configuration for SilverStripe
<?php
/*
* Payment
* ====================================================
*/
//Order notifications sent to
Email::setAdminEmail('test@example.com');
@frankmullenger
frankmullenger / gist:3102396
Created July 13, 2012 02:52
Validation Result
<?php
$result = new ValidationResult();
$result->error(
'Some message',
'VariationsDisabledError'
);
return $result;
@frankmullenger
frankmullenger / GridFieldConfig.php
Created September 13, 2012 03:08
GridField Detail form with relation ID populated
<?php
class GridFieldConfig_HasManyRelationEditor extends GridFieldConfig {
/**
*
* @param int $itemsPerPage - How many items per page should show up
*/
public function __construct($itemsPerPage=null) {
$this->addComponent(new GridFieldButtonRow('before'));
$this->addComponent(new GridFieldAddNewButton('buttons-before-left'));
<?php
class GridFieldDetailForm_ItemRequest extends RequestHandler {
//...
public function doDelete($data, $form) {
try {
$toDelete = $this->record;
@frankmullenger
frankmullenger / ResetDatabaseTask.php
Created April 30, 2013 03:54
Simple task to reset database using YAML file for SilverStripe, copies images over to assets/Uploads dir also.
<?php
class ResetDatabaseTask extends BuildTask {
protected $title = "Reset database";
protected $description = "Reset the database to a blank canvas";
static $fixture_file = 'builder/tasks/Reset.yml';
@frankmullenger
frankmullenger / EditableFileAttachmentField.php
Last active October 1, 2015 22:15
UserForms file attachments
<?php
/**
* Files that are uploaded only to be attached to emails and are not saved into assets.
*/
class EditableFileAttachmentField extends EditableFormField {
private static $singular_name = 'File Attachment Field';
private static $plural_names = 'File Attachment Fields';
@frankmullenger
frankmullenger / EmailPage.php
Created November 26, 2015 22:39
Simple GPG encryption test
<?php
class EmailPage extends Page {
}
class EmailPage_Controller extends Page_Controller {
private static $allowed_actions = array(
'Form'
);