I'm a bit confused.
This is the form_for in the Getting Started section of Paperclip's Github repository:
<%= form_for #user, :url => users_path, :html => { :multipart => true } do |form| %>
This is the form_for that is generated with Devise:
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
How should I modify it to get Paperclip working?
Just add :multipart => true to the :html parameter like so.
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :multipart => true }) do |f| %>
Related
I try to insert data in database but desn't work anyone help me please!
function saveDate()
{
if(Tools::getIsset('savedate'))
{
$value1 = Tools::getValue('value1');
$value2 = Tools::getValue('value2');
$res = Db::getInstance()->insert('ps_customer',array(
'lastname' => $value1,
'firstname' => $value2,
));
if($res)
return $this->displayConfirmation($this->l('Date saved'));
else
return $this->displayError($this->l('Error occured while saving date'));
}
}
Your query isn't working because you're not providing all required fields to create a customer object.
Here is the definition of Customer Object:
/**
* #see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'customer',
'primary' => 'id_customer',
'fields' => array(
'secure_key' => array('type' => self::TYPE_STRING, 'validate' => 'isMd5', 'copy_post' => false),
'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128),
'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 32),
'last_passwd_gen' => array('type' => self::TYPE_STRING, 'copy_post' => false),
'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate'),
'newsletter' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'newsletter_date_add' => array('type' => self::TYPE_DATE,'copy_post' => false),
'ip_registration_newsletter' => array('type' => self::TYPE_STRING, 'copy_post' => false),
'optin' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'website' => array('type' => self::TYPE_STRING, 'validate' => 'isUrl'),
'company' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
'siret' => array('type' => self::TYPE_STRING, 'validate' => 'isSiret'),
'ape' => array('type' => self::TYPE_STRING, 'validate' => 'isApe'),
'outstanding_allow_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isFloat', 'copy_post' => false),
'show_public_prices' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
'id_risk' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false),
'max_payment_days' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'copy_post' => false),
'active' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
'deleted' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
'note' => array('type' => self::TYPE_HTML, 'validate' => 'isCleanHtml', 'size' => 65000, 'copy_post' => false),
'is_guest' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false),
'id_shop_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false),
'id_default_group' => array('type' => self::TYPE_INT, 'copy_post' => false),
'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false),
),
);
You need to provide at least each field marked as 'required' => true
I am working on leave management system plugin so want to show application menu under lms menu.... here i past my init file code
menu :top_menu, :leave_transactions, { :controller => 'dashboard', :action => 'index' }, :caption => 'LMS' , :if => Proc.new { User.current.logged? }
menu :application_menu, :dashboard, { :controller => 'dashboard', :action => 'index' }, :caption => 'Dashboard' , :if => Proc.new { User.current.logged? }
menu :application_menu, :leave_transactions, { :controller => 'leave_transactions', :action => 'index' }, :caption => 'Apply Leave' , :if => Proc.new { User.current.logged? }
menu :application_menu, :holiday_informations, { :controller => 'holiday_informations', :action => 'index' }, :caption => 'Holiday' , :if => Proc.new { User.current.logged? }
Its working for me but application menu display all over menu. so i want to avoid this and when I click on lms menu that time application menu display..please help me
I have a print layout in haml for generating pdfs:
= link_to I18n.t('eda.print'), {:controller => :persons, :action => :print}, :method => '', :remote => false
Is there a way to have a javascript popup for confirmation like "are you sure?" just before executing the print method?
Non-javascript way:
= link_to I18n.t('eda.print'), {:controller => :persons, :action => :print},
:method => '', :remote => false, :data => {:confirm => 'Are you Sure ?' }
On clicking the link, it'll ask for user confirmation 'Are you Sure?' If you proceed further then respective controller -> action will be triggered.
I am trying to get rid of two required fields in prestashop's v1.5 user registration.
I want to set FirstName and LastName to not required.
To do so I removed the 'required' => true from both classes Address.php and Customer.php
But when I try to register I get the error: An error occurred while creating your account.
Any ideas why this happens?
Here's my Customer.php code:
public static $definition = array(
'table' => 'customer',
'primary' => 'id_customer',
'fields' => array(
'secure_key' => array('type' => self::TYPE_STRING, 'validate' => 'isMd5', 'copy_post' => false),
'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32),
'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'size' => 32),
'email' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'required' => true, 'size' => 128),
'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 32),
As you can see from the code it has only email and password fields set as required.
Did you try to set the required => false ?
'lastname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => false, 'size' => 32),
'firstname' => array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => false, 'size' => 32),
below is my mysql table define
class CreateStudinfors < ActiveRecord::Migration
def change
create_table :studinfors do |t|
t.string :cname , limit: 45, :null => false
t.string :ename , limit: 45, :null => false
t.date :birthday
t.string :gender , limit: 1, :null => false
t.string :address , limit: 45, :null => false
t.string :telephone , limit: 45, :null => false
t.string :mobile_phone , limit: 45, :null => false
t.string :school , limit: 45, :null => false
t.string :email , limit: 45, :null => false
t.boolean :work
t.boolean :study
t.boolean :travel
t.boolean :lifeplan
t.text :other , :null => false
t.string :sales , limit: 45, :null => false
t.string :introduce , limit: 45, :null => false
t.timestamps
end
end
end
this is my part of my form ..
<div class="field">
<%= f.label :make select %><br />
<%= check_box_tag "work" %>
</div>
any advise? thanks and please
Could you please show your form as well? If it is a form for a specific model such as:
<%= form_for #studinfor do |f| %>
<% end %>
Then you need to create the check box like this:
<%= form_for #studinfor do |f| %>
<%= f.checkbox :work %>
<% end %>