How can I create hints for extensions created with a 'pattern matching' defintion - asterisk

I have tried this:
[from-internal]
exten => _4XX,1,Dial(SIP/${EXTEN})
same => hint,SIP/${EXTEN}
After reloading dial plan, core show hints only showed the "unexpanded" hint.
This forced me to define the hint explicitly like this:
[from-internal]
exten => _4XX,1,Dial(SIP/${EXTEN})
exten => 400,hint,SIP/${EXTEN}
exten => 401,hint,SIP/${EXTEN}
exten => 402,hint,SIP/${EXTEN}
....
The only information I was able to find on this was the following which implies this must be possible.
Asterisk 1.6.1.x: It is now possible to specify a pattern match as a hint. Once a phone subscribes to something that matches the pattern a hint will be created using the contents and variables evaluated.
-https://www.voip-info.org/asterisk-standard-extensions/
What is the correct syntax for creating hints using pattern matching?

You can't.
Hints is hack. It work only with exact matching, sorry.
You can write script which will create hint for all extension in different file and include it into context usin "#include filename.conf"

You can do:
[from-internal]
exten => _4XX,hint,SIP/${EXTEN}
exten => _4XX,1,Dial(SIP/${EXTEN})

Related

How to embed an admin class into another one, without relation between them?

I could not find any solutions, and don't even know if possible, but can I embed an admin class into another one, withoug having a relation attribute between the two entities? I need to put a separate block near an edit form, but it would be a separate edit form, no relation between them.
This is what i am trying:
$formMapper
->with('Article', array('class' => 'col-md-8'))
->add('title')
->end()
->with('Terms', array('class' => 'col-md-4'))
->add('anyName', 'sonata_type_admin',array(), array(
'admin_code' => 'sonata.admin.term'
))
->end();
But of course this gives me a "The current field anyName is not linked to an admin." exception. Maybe there is another way to include two separate admins in the same page, or can I make this solution work? I would appriciate a step-by-step solution:) Thx!

gregwar/captchaBundle always message "code does not match"

I'm using the bundle of Symfony, Gregwar/CaptchaBundle. Itworks great exept that point: I need to renex the code to make it works, if not i have the message "code does not match".
I'm using it in the regitration form of the bundle FOSUser.
I tried to remove the renew option but it doen't make any change.
This is the code i use in my form:
$builder->add('captcha', 'captcha', array('as_url' => true, 'reload' => true));
Some one has an idea of how to resolve that? Or maybe there is another bundle i can use to do that?
Thank you and hope i was clear.
David

Redirect Error: No such label 'stdexten' in extension

i have install asterisk 11 on my server but when i want to redirect to extensions, i catch this error:
NOTICE[12657][C-00000043]: pbx.c:4475 pbx_extension_helper: No such label 'stdexten' in extension '305' in context 'DLPN_DialPlan'
WARNING[12657][C-00000043]: pbx.c:11825 pbx_parseable_goto: Priority 'stdexten' must be a number > 0, or valid label
ERROR[12657][C-00000043]: app_stack.c:547 gosub_exec: Gosub address is invalid: '305,stdexten(SIP/305)'
i think that this must be a bug in asterisk. anybody know about this???
I think that you are probably using a Goto with just an extension. This won't work - When using Goto, if you wish to go to a different exntension, then you must also specify the label or line number you want to go to.
Here's a useful reference on Goto in Asterisk
Here are the various combinations of parameters that work:
Goto(context,extension,priority)
Goto(extension,priority)
Goto(priority)
Goto(context,extension,label)
Goto(extension,label)
Goto(label)
Contexts are groups of extensions in extensions.conf. The start of a context looks like this: [Hello_World_Context]
Extensions are groups of commands that get executed if the call matches the number pattern. They're usually a bunch of commands which start with exten =>, such as: exten => 100,1,Answer
A priority is basically a line number. An example: exten => 100,1,Answer has a priority of 1.
A label can be used instead of a priority/line number. Example: exten => 100,n(extension_name),Answer - This has a label of exension_name
Goto([[context|]extension|]priority)
Set the priority to the specified value, optionally setting the extension and optionally the context as well. The extension BYEXTENSION is special in that it uses the current extension, thus permitting you to go to a different context, without specifying a specific extension. Please note that the LEADING arguments to Goto() are optional, not the trailing arguments.

Accessing values in Drupal's $form_values from a custom Drupal Form

EDIT: Seems like my "array-crawling" skills were not enough, thanks for the suggestions.
Moreover, I found out that I was checking the $discounttype condition with a plain "=" instead of a double "==". I guess banging your head on the same block of code for 3 hours makes you dumb and miss the most obvious errors.
First thing first, I'm on Drupal 6.
I have created a form with the following markup:
$form["cart_".$index] = array(
'#type' => 'image_button',
'#src'=> 'files/imghome/sidebar-add-demo.gif',
'#attributes' => array('rel' => '#item', 'class' => 'buybutton', 'title' => $discounttype),
'#prefix'=>'<p class="renewprop">'.$newren.' for '.$node_abb->field_tipo_abb_value.':</p><p class="renewblock"><span class="pricetag">'.$node_abb->field_prezzo_value.''.$discounttype.'</span>',
'#suffix' =>'</p>' ,
'#submit' =>array('usercp_form_submit'),
);
The form renders correctly, as you can see from this picture: http://cl.ly/3D2C2h1t1m2B351L1T31
(the N and R values beside the € symbol are actually the value of the $discounttype variable, just for checking it)
Each white box is basically an istance of the beforementioned form.
I need to pass the value of the $discounttype variable on each submit, so I decided to set it as the title of the submit button.
My problem is that in the submit function itself I cannot access the value of the 'title' attribute contained in the #attributes array. Mainly because probably I don't know the right syntax.
So far I've tried
$foo = $form_values['attributes']['title'];
$foo = $form_values['#attributes']['title'];
$foo = $form_values['attributes']['#title'];
And every other possible combination, but probably I'm just doing it wrong.
It's actually an hour that I'm crawling the web searching for an asnwer but I came up with anything.
first, you should mention form element ID.
so, you can access submit button by $form_state["cart_".$index]['#attributes']['title'];
but actually, why don't you use hidden field ('#type' => 'hidden') ?
I believe you have to use $form_state instead of $form_values. Give this a try:
$foo = $form_state['clicked_button']['#attributes']['title'];
I recommend using the Devel module while developing for Drupal. It is an extremely helpful tool during development, allowing you to see all the queries run when a page loads, stop a redirect to debug, and much more.

Most efficient way to have a 50 state drop down box in Drupal Forms

I know that one way is to have a table in database with all the states and then you would read it in your form. Is there any easier way in your opinion guys ?
I feel bad asking for something like this since it is so elementary however I would suppose something as simple like this would already be implemented in Drupal.
No need to hit the database. Build yourself a function that returns an array of the states.
$form['state'] = array(
'#type' => 'select',
'#options' => mymodule_states_list(),
'#title' => t('State'),
);
function mymodule_states_list() {
return array(
'AL' => 'Alabama',
'AK' => 'Alaska',
...
'WY' => 'Wyoming',
);
}
If you're building the form using Drupal's FormAPI you could just include the array of states in your module code since the names and abbreviations shouldn't be changing any time soon.
If you're trying to keep your code clean, you could save an array of states as a Drupal variable using variable_set() and then retrieve it using variable_get(). You really shouldn't need to bother with the database for that kind of thing.
That is one way to do it, sure. You can store a list of states as a variable, and call it.
$options = variable_get('mymodule_us_states', 0);
So long as it's an array. You could also have an internal function that returns the states.
Or store it in a flat file and read it in. Eg
Flat file =
$us_states_options = array(
'AL' => 'Alabama',
'AK' => 'Alaska',
//...etc
)
Function:
include_once(drupal_get_path('module', 'module_name') .'/us_states.inc');
All pretty ugly, but you at least can edit that file independently, and may work well if you have a larger list. Theres a million ways you could have the list included - using exec, fgetcsv/file, etc....
But I think ceejayoz solution is the nicest. I'd probably spin out those sorts of utility functions into a seperate include to keep it clean myself.
The Country codes API module also provides a Regions codes API module which include US states. With this module, you can get an array suitable for a Form API select element by calling regions_api_iso2_get_options_array('US').
Just remembered this question as I was experimenting with the Geonames module. Among tons of other features, Geonames includes the function "geonames_us_states()" which returns an array of U.S. states keyed by the states' two letter code.

Resources