I have the following code:
`$attachment = array(
'message' => "test",
'text' => 'Download',
'name' => 'name',
'href' => 'http://www.mydomain.com',
'description' => 'description!',
'media' => array(array(
'type' => 'mp3',
'src' => "http://www.mydomain.com/mp3.mp3",
'href' => 'http://www.mydomain.com/',
'title' => "title",
'artist'=> 'artist',
'album'=> 'the album')));
$facebook->api('/me/feed', 'post', $attachment);`
But when I publish the POST in my profile, it only shows the message "test". The mp3 file doesn't appear. What is the problem?
$attachment = array(
'message' => "test",
'text' => 'Download',
'name' => 'name',
'href' => 'http://www.mydomain.com',
'description' => 'description!',
'media' => array(
'type' => 'mp3',
'src' => "http://www.mydomain.com/mp3.mp3",
'href' => 'http://www.mydomain.com/',
'title' => "title",
'artist'=> 'artist',
'album'=> 'the album'));
$facebook->api('/me/feed', 'post', $attachment);
Related
I'm using an Image Captcha and I want to customize the "Captcha value is wrong" error message.
This is the definition of my Captcha:
$captcha = new ImageCaptcha();
$font = "./data/fonts/calibri.ttf";
$captcha->setFont($font);
$captcha->setDotNoiseLevel(55);
$captcha->setLineNoiseLevel(3);
In my form's constructor:
$this->add(array(
'type' => 'Zend\Form\Element\Captcha',
'name' => 'captcha',
'options' => array(
'label' => 'Please verify you are human.',
'captcha' => $this->captcha,
'messages' => array(
\Zend\Captcha\Image::BAD_CAPTCHA => 'super neat captcha message.',
),
),
));
I also tried:
$this->add(array(
'type' => 'Zend\Form\Element\Captcha',
'name' => 'captcha',
'options' => array(
'label' => 'Please verify you are human.',
'captcha' => $this->captcha,
'messages' => array(
\Zend\Captcha\AbstractWord::BAD_CAPTCHA => 'super neat captcha message.',
),
),
));
But I keep getting the "Captcha value is wrong" message.
The "message" part has to be in the captcha-options like this:
$this->add([
'type' => 'Zend\Form\Element\Captcha',
'name' => 'captcha',
'options' => [
'label' => 'Please verify you are human.',
'captcha' => [
...
'messages' => [
\Zend\Captcha\Image::BAD_CAPTCHA => 'super neat captcha message.',
],
],
],
]);
At least it works for me with Zend Framework 3.
Adding captcha element:
$this->add(array(
'type' => 'Zend\Form\Element\Captcha',
'name' => 'captcha',
'options' => array(
'label' => 'Please verify you are human.',
'captcha' => $this->captcha
),
));
And error message:
$this->getInputFilter()->get('captcha')->setErrorMessage('super neat captcha message.');
It works for me.
I can't figure out from official docs how to build a single checkbox element from the standard helpers. I already have the relevant boolean entity in database and I can build radios or selects as well for it, and they work.
But what I'd really like is to have a single checkbox to use as a boolean flag.
Anyone knows how?
Ok, the answer is to just use the 'switch' type: that will build a 'slider' switch on backoffice page. For future reference, I'm gonna report 3 different ways to accomplish the same task: radio, select and switch.
They have all been tested on AdminAddressesController and are bound to a custom DB boolean field called 'expo'.
//SELECT
$s_options = array(
array( 'expo' => 1, 'name' => 'Yes' ),
array( 'expo' => 0, 'name' => 'No' )
);
$temp_fields[] = array(
'type' => 'select',
'label' => $this->l('Is Expo'),
'name' => 'expo',
'required' => false,
'options' => array(
'query' => $s_options,
'id' => 'expo',
'name' => 'name'
)
);
//RADIO
$s_options = array(
array( 'id' => 'expo_on', 'value' => 1, 'label' => $this->l('Yes')),
array( 'id' => 'expo_off', 'value' => 0, 'label' => $this->l('No')),
);
$temp_fields[] = array(
'type' => 'radio',
'label' => $this->l('Is Expo'),
'name' => 'expo',
'required' => false,
'class' => 't',
'is_bool' => true,
'values' => $s_options
);
//SWITCH
$s_options = array(
array( 'id' => 'expo_on', 'value' => 1, 'label' => $this->l('Yes')),
array( 'id' => 'expo_off', 'value' => 0, 'label' => $this->l('No')),
);
$temp_fields[] = array(
'type' => 'switch',
'label' => $this->l('Is Expo'),
'name' => 'expo',
'required' => false,
'is_bool' => true,
'values' => $s_options
);
Subject: How to put a picture instead of text in radio element in ZF2?
code:
Options field:
array(
'spec' => array(
'type' => 'radio',
'name' => 'fcaptcha',
'options' => array(
'label' => 'Капча',
'label_attributes' => array(
'class' => 'control-label',
),
),
'attributes' => array(
'required' => 'required',
),
),
)
Controller:
$temp[0] = 'Here you need to put a picture instead of text';
$temp[1] = 'Here you need to put a picture instead of text';
$form->get('fcaptcha')->setValueOptions($temp);
You can do that just with some CSS. Here's a simple example that you can adapt for your purpose :
Let say you have this Zend\Form\Element\Radio element :
array(
'type' => 'Zend\Form\Element\Radio',
'name' => 'fcaptcha',
'options' => array(
'value_options' => array(
'0' => 'something1',
'1' => 'something2',
),
),
'attributes' => array(
'id'=>"fcaptcha-id"
)
)
CSS :
radio-option1 {background-image:url(option1.png);}
radio-option2 {background-image:url(option2.png);}
Some JS :
$(document).ready(function(){
$(':radio[value="0"]').addClass('radio-option1');
$(':radio[value="1"]').addClass('radio-option2');
});
I have a function to reset a password.
At the point where I have to compare the password and the password_confirm field, I get a strange behavior:
My form
echo $this->Form->hidden('tkn', array('value' => $tkn));
echo $this->Form->hidden('uid', array('value' => $uid));
echo $this->Form->input('password',array('type' => 'password', 'name' => 'data[Appuser][password]'));
echo $this->Form->input('password_confirm',array('type' => 'password', 'name' => 'data[Appuser][password_confirm]'));
My model validation:
var $validate = array(
'password' => array(
'rule' => array('minLength', '6'),
'message' => '{password} minLength 6!'
),
'password_confirm' => array(
'rule' => array('equaltofield','password'),
'message' => '{password_confirm} not equal!'
),
);
function equaltofield($val1, $val2){
return $this->data[$this->alias][key($val1)] == $this->data[$this->alias][$val2];
}
My Controller:
if($this->Appuser->save($this->data)){
$this->Session->setFlash(__('Password has been updated'));
}else{
debug($this->Appuser->invalidFields());
}
Now:
When I submit an empty form I get the following returned from the invalidFields()
array(
'password' => '*****',
'password_confirm' => array(
(int) 0 => '{password_confirm} not equal!',
(int) 1 => '{password_confirm} not equal!'
)
)
Question 1: Why do I not get the message, that the password has not its minlength?
Question 2: Why do I get the second message twice for comparing the password?
When typing in 2 different password with min length, I get this again:
array(
'password_confirm' => array(
(int) 0 => '{password_confirm} not equal!',
(int) 1 => '{password_confirm} not equal!'
)
)
When debug($this->data) I also get this (if that helps somehow)
array(
'Api' => array(
'tkn' => '6837d241bf1076c3c55a95abbcfafa04dc19a33c',
'uid' => '1'
),
'Appuser' => array(
'password' => '*****',
'password_confirm' => 'asdfgh'
)
)
Any ideas regarding my two questions above?
Thanks in advance!!
Try this
var $validate = array(
'password' => array(
'rule' => array('minLength', '6'),
'message' => '{password} minLength 6!'
),
'password_confirm' => array(
'rule' => 'equaltofield',
'message' => '{password_confirm} not equal!'
),
);
function equaltofield($data){
return $this->data[$this->alias]['password'] == $this->data[$this->alias]['password_confirm'];
}
Good evening,
I have the following option in Redux Framework (version 3.1.9):
array(
'id' => 'social-networks',
'type' => 'sortable',
'mode' => 'checkbox',
'title' => __('Order Social Icons', 'options'),
'subtitle' => __('Order and activate/deactivate social icons', 'options'),
'options' => array(
'fb' => 'Facebook',
'tw' => 'Twitter',
'lin' => 'LinkedIn',
)
),
And the output (if all three options are checked) is:
[fb] => 1
[tw] => 1
[lin] => 1
After this option I want to display a text field for every checked social network in this list and I have the example text input:
array(
'id' => 'facebook-url',
'type' => 'text',
'required' => array('social-networks["fb"]','equals','1'),
'title' => __('Facebook URL', 'options'),
'subtitle' => __('Enter your Facebook URL.', 'options'),
),
Of course the "required" argument doesn't work.
Is there a way to use this argument by using an option from a field and not only the ID.
Thanks
According to http://docs.reduxframework.com/redux-framework/arguments/required/, your conditional option should look like this:
array(
'id' => 'facebook-url',
'type' => 'text',
'required' => array('social-networks','equals','fb'),
'title' => __('Facebook URL', 'options'),
'subtitle' => __('Enter your Facebook URL.', 'options'),
),
Next option:
array(
'id' => 'twitter-url',
'type' => 'text',
'required' => array('social-networks','equals','tw'),
'title' => __('Twitter URL', 'options'),
'subtitle' => __('Enter your twitter URL.', 'options'),
),
and so on.