backpack for laravel getting link id - laravel-backpack

i need to export an specific record into pdf , so i created a inline button using addbuttomfrommodel function, now i need to pass the id of the specific record to the model where the route is created, how can it be done?
In model i have problem to pass the record ID in the href.so i can export only the specific record.
in model
public function getExportarButton() {
return "<a class='btn btn-primary' href='exportar_ficha'>Exportar A Documento</a>";
}
thanks ini advance

The entry object is available in your custom blade file as $entry

Related

how to create a form elements with value in moodle

I am trying to create a form element text with value in moodle.
I trying the below :
$mform->addElement('text','test', get_string('test'));
This is used to create a text box . i want to add value also like
<input type='text' value='<?php .... ?>' />
How to do that in moodle
When you instantiate the form, you can pass the relevant data into it, e.g.
$form = new my_form();
$formdata = (object)array('test' => 'The value to display in the textbox');
$form->set_data($formdata);
(Usually the data passed into the form is some existing data retrieved from the database).
I'm not sure what kind of data did you mean here.
If you want to set user data (for example, you are developing a form that edits existing record), then use $form->set_data() after creating a form instance as Davo suggested.
If you want to pre-fill the form with default value, then use this inside the form definition:
$mform->addElement('text','test', get_string('test'));
$mform->setDefault('test', 'your default value');
You can use both methods, in which case the data from set_data() will have priority.

SilverStripe custom form retrieve values for form fields

I have a problem with my front end admin update page. How can I retrieve values from a SiteTree page and populate it into a custom form? Is the setValue($values) function the only way? If yes, which is the best method to get the page variable?
I am using this:
$evens = Versioned::get_by_stage('PageCalendrierEvenement', 'Stage')->byID($evenID);
I'm getting values from an ID of a draft page. After I get variables and values like that:
$field = new TextField('Titre', 'Titre');
$field->setValue($evens->Titre);
or
new TextField('Titre','Titre', $evens->Titre);
Which is the better solution?
The solution is 2 part:
Use TextField::create($constructor, $args) instead of new (optional, but not doing so is a pet hate of mine).
Set all fields at once: http://api.silverstripe.org/3.1/class-Form.html#_loadDataFrom

Add a non database attribute to order email

we have a single attribute which is shown on single product page. Attribut Name is lieferkW. For any order of a product i want to send the content of this attribute to our customers in the order email.
i dont want to save the content of this attribute in database. Do you have any solution for my problem?
You can use other resources, like the session, the local storage, or a temporary file.
However, I would suggest that you should store this in the database and remove it when you send the email. You could have a table like this
temporary_attributes(id, userId, attribute, orderId)
insert it when you need it and remove it once you have sent the email.
To include your custom attribute lieferkW in your sales order email, make these changes
1) Open \app\code\core\Mage\Sales\Model\Order.php
$customAttr = 'custom_value'; // the attribute "lieferkW" value
$mailer->setTemplateParams(array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'payment_html' => $paymentBlockHtml,
'custom' => $customAttr //your custom value here
)
);
2) Now change the email template located at \app\locale\en_US\template\email\sales\order_new.html
You can access you variable here like
{{var custom}}
P.S. I advice not to make changes in the core files.

CakePHP form data to session

I'm facing a problem with CakePHP. I have two pages, on first page user will enter data in form and on second page, he will see a printable data for the form (sort of confirmation).
Since the form is big and contains 20+ fields, I don't want to read them using $this->params.
I'm using the following code:
function birthconfirm(){
$this->loadModel('Birth');
$birth = new Birth();
$birth->set($this->data);
$this->Session->write("birth", $birth);
$this->set("birth", $birth);
}
Birth is the name of the model here. There is another view birthconfirm.ctp which is not reflecting the data passed on the last line. I tried to use following lines on the next view but of no use:
echo $this->birth["Birth"]["birth_date"];
echo $this->birth->birth_date;
Use the below code to set birth for birthconfirm.ctp
function birthconfirm(){
$this->Session->write("birth", $this->data);
$this->set("birth", $this->data);
}

Unique field in user registration form in Drupal 7

I am working in drupal 7. I need a field in the user registration form which needs to be unique. It is an integer field which stores the ID of the user. I have been searching around for a few hours now without any development. Can someone guide me through this?
Thank You.
You can add a custom "staff id" field to the user entity type from admin/config/people/account/fields (configuration->people->account settings). You can add a new integer field, and mark it to display in the registration form, and/or required.
To check that the field value is unqiue you will need to use a custom module. In your custom module use the form_id_form_alter hook to add a custom validation to the registration form. Then during validation you can check that the value does not already exist in the database and return a form error.
Example of the custom module:
<?php
function mymodule_form_user_register_form_alter(&$form, &$form_state, $form_id){
$form['#validate'][] = 'mymodule_user_registration_validate';
}
function mymodule_user_registration_validate(&$form,&$form_state){
$staff_id = $form_state['values']['staff_id_field'];
$check_unique_query = 'SELECT field_staff_id_value FROM {field_data_staff_id} WHERE field_staff_id_value = :staff_id LIMIT 1';
//if a result is returned, that means the $staff_id exists
if (db_query($check_unique_query,array(':staff_id'=>$staff_id))->fetchField()){
form_set_error('staff_id_field','This Staff ID is already in use');
}
}
Have you tried the Unique field module? Pretty sure it does what you need here.
Field validation does the trick https://drupal.org/project/field_validation. You can set any rules per field even on the registration form